Luke Smith Write today, wrong tomorrow

Creating website installer using WiX

I’m currently working on a new project and one of the things I want is an easy deployment process. Rather than wait till I actually want to deploy the site to production to put something in place I’ve decided to build it early and use the same process as part of my CI process. Testing the process early and often will mean any issues will be solved sooner rather than on the day of the release.

I decided to go with an msi installer, so had 2 choices. Either using a Setup Project, that’s included in Visual Studio, or WiX. WiX is far more powerful, and also doesn’t require Visual Studio being installed on the build machine (Setup Projects aren’t supported by MSBuild and so you have to use devenv.exe to build them…urgh).

WiX is a Windows Installer toolset and you write your installation packages using XML. It’s a Microsoft project and hosted on sourceforge.

The following uses wix3.0.5419 and requires Visual Studio 2008.

Step 1: Download WiX

Download WiX from sourceforge. Make sure you also install Votive (included in the WiX installer) which will give you support for creating WiX projects inside Visual Studio with full intellisense.

Step 2: Create a new WiX project

Simple, just as you would any other Visual Studio project.

Step 3: Adding the WixIIsExtension

WiX provides a template to work with when creating a new project, which is useful. The first thing we need to do is reference to WiXIIsExtension, which provides us with the tasks needed to create websites and virtual directories from the installer. References are added in the same way as any other project reference, via the Solution Explorer.

 

You then need to add a new xml namespace to the Wix root element in your Product.wxs file. If you don’t do this then I’ve found you cannot make use of the tasks provided by the extension library and will get the error “The Component element contains an unexpected child element 'WebSite'.”

Add the namespace xmlns:iis=”http://schemas.microsoft.com/wix/IIsExtension”.

Step 4: Creating the website

In the Product.wxs file you can now add a task to create a website in IIS within a Component.

 

Update the ComponentRef under the Feature Id=”ProductFeature” to point to the Website component, Ctrl+Shift+B and you’ve created an installer that creates a website under IIS.

Step 5: Run the installer and view the result

Find the installer that is produced in the bin directory and run it. There is no UI for the user to interact with, and a new website is created pointing to C:\Project Files (x86)\WixSampleProject

 

We’ve not included any files in our installer, for that I use heat which I’ll blog about in a future post.

Hope you’ve found this helpful

Technorati Tags: ,,,
comments powered by Disqus