WiX’in Up with XML

Creating installation packages is not something any developer likes to see on their task list because of the complexities that present iteself but it is a necessary evil to get software installed on an end users machine. There are some very good third party tools available that aid in reducing these complications (e.g. InstallShield, ActualInstaller, CreateInstall, etc.) but there is an alternative to purchasing one of these software bundles. The old adage of “build vs. buy” need not apply here as to create a robust deployment package (the build) doesn’t involve a lot of work and best of all – it’s free (the buy)!

I’m speaking of course of using the Windows Installer XML (WiX) toolset. 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. This ties in well with Team Foundation Server (TFS) and with Visual Studio’s pre/post events for builds.

Having no experience with this toolset I dove right in after downloading and installing it. There are some pre-canned UI wizards that do indeed help speed up the process of creating a setup package and the integration with Visual Studio is tightly coupled. I created a sample Windows Forms application, added a WiX project and within a matter of minutes I created my first WiX based setup package.

I found the help documentation extremely valuable especially when I was customizing the XML. There are plenty of samples that illustrate what parts need to change in order to accomplish a certain action and it’s as simple as copying and pasting the provided XML snippets into a project.

WiX also offers a set of built-in custom actions that can be used and incorporated within Windows Installer packages. The custom actions are offered in a set of WiX extensions. Some common WiX extensions include support for Internet Information System (IIS), Structured Query Language (SQL), the .NET Framework, Visual Studio, and Windows.

Using the aforementioned features couldn't be easier. Just add a reference to that particular assembly (e.g. WixUIExtension, WixUtilExtension, WixSQLExtension, etc.) and now any references in the XML that utilize that extension (e.g. WixUI_FeatureTree, InternetShortcut, etc.) will resolve correctly.

Resources

Windows Installer XML introduction by Rob Mensching

Automate releases with MSBuild and Windows Installer XML

Step-by-Step Wix Tutorial

Summary

WiX is a viable option for creating stable, professionally functioning deployment packages and is extensible to fit most developer’s requirements.