June 3, 2014

3585 Views

Install a Website, Windows Service and Database using WiX Installer

In this blog, I will be explaining the creation of the installation package to Deploy Website, Create AppPool, Create Database with Script and Install Windows Service. To create installation package I have used WiX toolset.

Why choose WiX to create Installer?

It is an XML based open source toolset to build Windows Installation packages. WiX is easy to understand and has lots of inbuilt libraries for UI, command line utilities, that help to create a quality package installer.

Download latest WiX release from: http://wixtoolset.org/releases/

First step:

Keep a machine ready with following pre-requisites software:

  • Windows 7/Windows Server 2008 R2
  • Wix 3.9 or greater version
  • Visual Studio 2010 or greater version

Create Project in Visual Studio

Create new Windows Installer XML->Setup Project from Visual Studio IDE. Add following files in the project:

  1. Products.wxs
  2. UI.wxs
  3. Files.wxs

Add assemblies and references

You will need to add references of following dlls into the project:

  1. WixIIsExtension.dll
  2. WixUIExtension.dll
  3. WixUtilExtension.dll
  4. WixSqlExtension.dll

Change content of Product.wxs file

Product.wxs contains Installation/Upgrade Version details, App Pool, Virtual Directory and UI references. Below mentioned code snippet is for Installation version and up gradation key:

Before deploying website, check whether IIS is installed or not:

Add following lines to create app pool and virtual directory for website.

Add custom and inbuilt dialogs to installer

Define features list and dialog boxes in UI.wxs file. Publish dialog(s) as per your requirement, like “WelcomeDlg”, “LicenseAgreementDlg”, “CustomizeDlg” etc.:



Add custom dialog box to take user credentials, follow below mentioned lines:

Harvest files and folders for installer

Go to WiX install location\bin folder and from command prompt run the following to harvest files/folders of your applications:

heat dir c:\yourbinariesfolders  -gg -g1 -sfrag -cg WhatThe -out Files.wxs

Above command will generate Files.wxs Add this file to Installer project.

Change component to enable Windows service installation feature

In Files.wxs, you need to do the following changes to enable installer for windows service installation:

Execute sql script

In Files.wxs, add a component as below mentioned:

Add Sql file as binary.

Change product name and package description.

Compile the project to produce .msi file and this can be used to install software package.

This is a complete, all-in-one installer that installs Website, creates AppPool, sets user Identity, Installs windows service and runs the database script.

References:

To get more details visit:

http://wixtoolset.org

http://wixtoolset.org/documentation/manual/v3/wixui/wixui_customizations.html

http://www.dizzymonkeydesign.com/blog/misc/adding-and-customizing-dlgs-in-wix-3/