Installing a Web Application to an Existing IIS Website using Wix3


Using Type 35 Custom Actions":

3.5    The InstallDirDlg
As shown below, the new application will be installed to a new virtual directory under the picked website root directory plus the new virtual directory if there is any:

3.6    Three Ways about Sequence
The real difficult part is to find out how to properly queue the new dialog and these two Custom Actions in the installation sequence. After tons of reading and experiments, finally I got it work in one way. The right sequence we want is like this:

WelcomeDlg --> Custom Action 1 --> ConfigSFSDlg --> Custom Action 2 --> Custom Action 3 --> InstallDirDlg

  1. Custom Action 1 finds the websites.
  2. ConfigSFSDlg displays the websites, and user picks one of them.
  3. Custom Action 2 finds the picked website's root directory.
  4. Custom Action 3 will set the installation path under the website's root directory.
  5. InstallDirDlg displays the path the new application will be installed to.



3.6.1    In the Sequence Tables
We'll queue our Custom Actions in InstallUISequence because we need to provide and get information from the user. You need to add the same into InstallExecuteSequence if you want to provide quiet installation.

Custom Action 1 has to be run before the new dialog ConfigSFSDlg is created. So we will queue this action right before the standard dialog PrepareDlg. The following code put this action in the right place:


And below is the InstallUISequence table in the result mis file:


3.6.2    In the ControlEvent Table
For Custom Action 2, I found no way to put it in the right place using the same way as the Custom Action 1. So I used another approach: the custom action will be called right after the user picks the website and click the Next button in the ConfigSFSDlg.

You can find a good sample code here regarding this approach:

3.6.3    By a Call to Session.DoAction()
Custom Action 3 is called inside the Custom Action 2 with the following code:
Session.DoAction("SetSFSInstallPath2"). SetSFSInstallPath2 is Custom Action 3's name defined in Wix.

All three approaches are well explained in Boneman's Blog here:

These are three Custom Actions in the result msi file:


4    Add a New Dialog in Wix3
In Wix2, you'll have to make changes in the Wix source code and recompile the Wix2 UI library in order to add a new customized dialog into a standard installation UI sequence. So I ended up with migrating all Wix2 code to Wix3.

Below is an extraction from WixWiKi:
"The stock Wix user interface sequences, UiExtension, do not support inserting a custom dialog. However the underlying dialogs have been carefully constructed such that the navigation logic, the back and next buttons, is not part of the dialog itself. The navigation logic is actually defined as part of the sequence itself. What this means is that you can build your own custom UI sequence using just plain old Wix."

The basic steps are:
1.    Design UI of the new dialog, e.g. ConfigSFSDlg2.wxs, in my example.
2.    Make a copy of a standard user interface, e.g. WixUI_InstallDir.wxs.
3.    Insert your new dialog into UI sequence by modifying the above WixUI_InstallDir.wxs and rename it to, e.g. WixUI_InstallDir_SFS.wxs in my example.
In Wix3, the sequence of dialog is controlled by Event Publishing of Next/Back buttons as shown below.


Then in your main wxs file, reference your modified UI sequence wxs file as shown below:


 Jirong Hu is a software development consultant specialized in configuration management, build and release management. He has lots of experience in J2EE development with IBM Rational tools, and currently he's working on .Net application's build and packaging

About the author

AgileConnection is a TechWell community.

Through conferences, training, consulting, and online resources, TechWell helps you develop and deliver great software every day.