Yet Another WiX Tutorial Part 1 : An Introduction

WiX WiX in a nutshell

Quote:

The Windows Installer XML (WiX) is a toolset that builds Windows installation packages from XML source code. The toolset supports a command line environment that developers may integrate into their build processes to build MSI and MSM setup packages.

I could not have said it better myself.

The main components

The three mains components I use from the toolkit are the following.
(Although i found another useful one called heat.exe that I'll explain in a later tutorial)

  • candle.exe : used to compile a WiX file
  • light.exe : used to create the MSI from the compiled file
  • dark.exe : used to decompile a MSI into a WiX script

wix components

The usage of WiX

Introduction

In one of the projects I'm working on we use Windows Installer XML (or WiX) to create a setup package during the automated build process. Although we have the build process under control, and we have a generic way of integrating WiX in our build process i wanted to know more about WiX, and see if i could optimize it.

The way the the initial WiX script was created is by taking a working MSI package, that contains a custom installer class, and decompile it to a WiX script. Cleaning it up and adding the appropriate settings (like product name and version) and than create some project specific settings we supply to the WiX compiler using parameters to build the MSI.

Why go trough all this trouble you might ask. Visual studio has a nice setup project template that build using MSBuild as well. Of course that’s true, but it is limited in what it can do. At least we found ourselves writing a lot of logic in a custom installer class, and adding that to the project. Another small detail was updating the version number of the setup during build.

As i found out later, some of this logic was actually supported by WiX and made it all easier as well. That’s why I've put all my findings together and started created this step by step tutorial series.

An example

We use custom code to install a virtual directory under IIS and map it to the web application that comes with the installation.  This can actually be done using simple WiX code … and … it’s transactional. No custom rollback or uninstall code.

Another thing we do is that we pack our web applications in a ZIP archive, and add this to the installer. Using the custom installer, we unzip it. This also means that we have to write uninstall logic, as de MSI only knows about the zip file included. I looked into a better solution and found a more generic way to include all the files from a web application, or build output folder, and include the file in the installer. With this solution you are skipping the rollback and uninstall logic, unzipping and install folder cleaning.

Last interesting thing was windows services. We now install them using a custom action. This means that again we have to write rollback logic and uninstall logic. This was error prone because if the service was still running it can’t be deleted.

Conclusion.

Although WiX has a slight learning curve, in the end a good WiX script leave a lot of installation, rollback and uninstall logic to the windows installation process leaving more time to write only the pre installation logic, like configuration dialogs, in the custom installers (although this can also be done using WiX).

The WiX Toolkit

Getting the toolkit

Installation is a piece of cake. Download the latest “RC” version from the SourceForge.Net page. During the course of these tutorials I will be using version 3.0.5217.0.

installation

With the installation you get the complete command line toolset. Besides that Votive is installed. This is the visual studio package. It add a new project type to visual studio, including 5 new project templates. I will come back to this in a next tutorial.

wix vs2008 template

A final suggestion

I recommend adding the installation path of the toolkit (default: “C:\Program Files\Windows Installer XML v3\bin”) of WiX to your environmental variables, so you don’t have to type the whole path every time you run a script from the command line.

What’s in the next part

In the next part of the tutorial I will guide you trough creating a basic installation from scratch, using the WiX project template in visual studio.

Comments

Popular posts from this blog

Yet Another WiX Tutorial Part 3: Customizing the UI dialogs

Encrypted Cookies using ASP.NET

Yet Another WiX Tutorial Part 2: Your First Installer