Installing a Web Application to an Existing IIS Website using Wix3

[article]

host headers or IP addresses in Visual Studio 2003 or in Visual Studio 2002 Service Pack 1"
http://support.microsoft.com/default.aspx?scid=kb;en-us;821335

However, after a bit of experimenting, I found that fix probably only applied to those Web Setup projects created from Visual Studio. In our case, the msi file is created by Wix. That javascript doesn't work on our msi file, no matter how I try to recompile our project with that new DPCA.dll.

3    The Wix Solution
So I was on my own. After some hard work searching on Internet, I figured out this procedure to get the job done. Here is what needs to be changed to our existing Wix code:

  1. First I need to create a new dialog for this screen.
  2. Then I need to add the new dialog to our standard installation sequence. This dialog will be added right after the Welcome dialog and before the InstallDir dialog, because we need to change the installation path in InstallDir Dialog.
  3. We need to display all existing IIS websites in the new dialog. Assume a Custom Action to be run right before the new dialog is created.
  4. After the user picks a website, we need to find out its root directory to be used as the installation path in the InstallDir dialog. Assume another Custom Action can do this job.

Please note in the following sample, I borrowed a lot of source code from various places on the Internet. To list a few:

  1. Vallery's Post: http://osdir.com/ml/windows.devel.wix.user/2005-07/msg00020.html
  2. Chris's IISFAQ: http://www.iisfaq.com/Default.aspx?tabid=2989
  3. Alex's Wix Blog: http://blogs.technet.com/alexshev/archive/2008/02/21/from-msi-to-wix-part-5-custom-actions.aspx

3.1    The New Dialog: ConfigSFSDlg
Below is my prototype code for this dialog. I have to add the hidden ComboBox with an item, otherwise the ComboBox doesn't appear in the msi table, and the Custom Action won't work. It will be good to fix this issue, but I am still new to Wix and my knowledge in msi is very limited. I've already ordered this book and hopefully that can help me out: "The Definitive Guide to Windows Installer", by Phil Wilson.
jhaug09-2small.jpg

In this dialog, the edit box allows user to enter the new virtual directory to be created under an existing website. The ComboBox with property name called "TARGETWEBCOMBO" will be used to display all websites as shown below. The content of TARGETWEBCOMBO will be filled in from the Custom Action 1.
jhaug09-3.jpg

3.2    Custom Action 1: Display Websites
The hard work of finding all existing websites is done by the following Custom Action called caDisplayWebSites. It retrieves information of existing website from local machine and modifies the msi table.

This is a Type 6 Custom Action. Alex's blog has some good examples for all types of Custom Actions: http://blogs.technet.com/alexshev/archive/2008/02/21/from-msi-to-wix-part-5-custom-actions.aspxjhaug09-4small.jpg

3.3    Custom Action2: Find the Website Root Directory
Once the user picks one of the websites in ConfigSFSDlg dialog, we need to find out the root directory of this website, in order to install our new application SFS underneath it. For example, in the screen below, the user picks the website called OnlineGuilde and specified a new virtual directory SFS: jhaug09-5.jpg

The job to find out the website root directory is done by another custom action called caReturnWebSiteRootPath as shown below:
jhaug09-6small.jpg

Please note that I have to manipulate the "Default Web Site" differently because of that hidden ComboBox we have in the new dialog. It will be good if I can clean up these mess.

3.4    Custom Action 3: Set the Install Path
Custom Action 3 "SetSFSInstallPath2" set the installation path to the new website's root directory.

It is a Type 35 Custom Action which many say it should be replaced by a Type 51 Custom Action.

"Be Careful

About the author

TechWell Contributor's picture TechWell Contributor

The opinions and positions expressed within these guest posts are those of the author alone and do not represent those of the TechWell Community Sites. Guest authors represent that they have the right to distribute this content and that such content is not violating the legal rights of others. If you would like to contribute content to a TechWell Community Site, email editors@techwell.com.

AgileConnection is one of the growing communities of the TechWell network.

Featuring fresh, insightful stories, TechWell.com is the place to go for what is happening in software development and delivery.  Join the conversation now!

Upcoming Events

May 04
May 04
May 04
Jun 01