If you remember some of the early pronouncements about .NET you probably heard the one where using .NET meant you could just XCOPY your binaries to the server and run them. No wrestling with the difficult Windows Installer technology or strange third party tool to create an installation, just the pure nirvana of copy and run. Of course, the reality is radically different. Nearly any application that’s running on a Windows-based operating system needs to have an installer. The problem is that still today the install development is left as an afterthought or sloughed off to some junior developer or intern. The install is part of your code just like anything else so you need to treat it as a first class citizen.

If you’re not planning out and testing your installation throughout your development cycle, the user’s first impression of your application will be a little less than positive. Everyone reading is now shaking their heads “yes” because we’ve all been through that nasty experience of an install that doesn’t work. It’s not only the end user that needs that install– the developers need the installation throughout the development phase, because having the easy and clean way of getting a debug or release build on a test machine saves huge amounts of time. If developers have to go through a five page manual checklist to get the application running on a computer, they are wasting valuable development time. Also, being able to install and uninstall makes it far easier to ensure the application is running consistently on multiple machines.

While there are many third party applications, commercial and free, available to developers, I want to focus on a free tool, Windows Installer XML (WiX), which I’ve been using to build my installations for the last couple of years. By the way, WiX was Microsoft’s first real open source project. I must make the disclaimer right up front that I am certainly not an installation expert. Like nearly everyone reading this, I’m just a developer (and sometimes project manager) who wanted the installs to be part of the code right from the beginning.

If you’re worried that you have a complicated application and WiX might not be able to handle it, rest assured. WiX has been used to build some installations that you’ve used in the past. A few small applications such as Microsoft Office 2007, Microsoft SQL Server 2005, and Microsoft Visual Studio 2005/2008 are a small sample. WiX is the installation tool of choice inside Microsoft.

In the first part of a three part series, I want to discuss resources and hints for those of you who have not used WiX before. In the second part, I want to cover one of the biggest problems with WiX which is that it doesn’t make life easy during development when binaries and supporting files are in a state of flux. This is especially true in web applications where user interface designers are adding and removing files, such as .JPG images, that aren’t really under the developer’s control. WiX currently forces you into a model of huge amounts of time spent manually editing the installation files. In the final part of the series, I want to present a tool I wrote that solves those problems and which has definitely taken the time spent working on my installations from days to minutes when dealing with rapidly changing projects.

WiX is a set of tools that transforms .WXS files, which are nothing more than XML files following the WiX schema, into your .MSI file installation. There are two versions of WiX for you to choose from. The feature complete, stable version is 2.0 and only has one or two bugs left to fix. You can download the 2.0 release at http://sourceforge.net/project/showfiles.php?group_id=105970&package_id=114109. I’m going to focus on WiX 2.0 for this series, and with a tool I’ll present in the final installment. WiX 3.0 is currently under development and will include many interesting new features to make your installation life easier. One of my favorite updated features is a much improved Visual Studio package, called Votive, which makes WiX installs full MSBUILD-compliant projects, allowing you to edit and create them inside Visual Studio Other great features include a much easier way to specify custom user interface dialogs, and excellent patch creation support. However, the WiX developers have been very consistent in telling everyone that WiX 3.0 is under development and you shouldn’t trust it yet to build your installations because it’s in a state of flux. The other problem with WiX 3.0 is that there’s essentially no documentation on it yet, which is the bane of most open source projects. I’d highly recommend that you stick with WiX 2.0 until Rob Mensching, the lead developer, says WiX 3.0 is finished, which should be sometime in late 2008.

If you’re a neophyte install developer, you’re going to run into trouble using WiX. It’s not WiX’s fault. Nearly all the hassle and pain you’re experiencing is from the Windows Installer technology itself. If you don’t have a basic understanding of Windows Installer, WiX will be much more difficult to use and understand. The best place to get started is with the Windows Installer documentation itself. Unfortunately, the documentation is written as if you already understand Windows Installer intimately. Many of the other resources related to installer technology you’ll find on the Internet are for third party products, so you should definitely take the time to read the real documentation.

While I have been around Windows development for a very long time, I can’t help but think that the Windows Installer design seems far more complicated and painful that it needs to be. I’m the first to admit, however, that I’m not installation expert. However, 90% of the installations are just installing files, setting registry options, and other simple tasks. If you look at how few teams do installs, or utilize complete workarounds, such as InstallUtil.EXE, to avoid using Windows Installer, I think my assessment is not too far off. Sadly, we are stuck with the Windows Installer API as it is, so we have to deal with it. At least using WiX does make using Windows Installer a lot more palatable instead of doing all the work manually with the tools included in the Platform SDK.

After you’ve read over the Windows Installer documentation, you’re going to spend a lot of time at Gábor Deák Jahn’s excellent WiX Tutorial at http://www.tramontana.co.hu/wix/. Gábor’s tutorial does not cover every single detail of WiX but does a great job of getting you into the philosophy of WiX. The best part of the tutorial is that Gábor gives you the sample code for all the techniques he shows, so you can play with them yourself and see how everything works. We all owe Gábor a major thank you because if it wasn’t for his WiX Tutorial, we’d have no idea how to get past a WiX “Hello World” installation.

For more advanced questions and help, you can turn to http://wix.mindcapers.com/wiki/Category:WiX or your favorite search engine to look for the answer. One of the best places for help is the Source Forge WiX mailing list, http://sourceforge.net/mailarchive/forum.php?forum_name=wix-users. If you ask a well prepared question on the mailing list, you’ll get your answer. To look for past answers, I like to use http://news.gmane.org/gmane.comp.windows.devel.wix.user for searching.

The final getting started trick I want to mention is about using the WiX schema, which happens to be an excellent example of how to use documentation tags. As with any schema, reading the WiX.XSD file to learn the exact order of elements is probably how you don’t want to spend your time. When you start editing your own .WXS files, you’ll want to take advantage of Visual Studio’s excellent schema support by copying the .XSD files from the <WiX Directory>Doc to <Visual Studio Directory>XmlSchemas. Once copied, you’ll get the red squiggly lines indicating errors, auto completion for attributes, as well as tool tip help when you mouse over an element.

If you’ve never looked at WiX, I hope that gives you some starting points. Of all the installation tools, WiX is the best I’ve used. In the next installment of this series, I want to discuss some of the problems with WiX so you’re aware of them.

Edit: Read part two, here.