WiX

WiX is a toolset to create MSI-files. It was the first open source software from Microsoft.

License and Download

WiX is free, open source, and can be downloaded from wix.sourceforge.net wixtoolset.org.

I recommend to use version 3.5, because with newer versions I had nothing but trouble.

Direct download links:
WiX35.msi
WiX36.exe
WiX37.exe

Requirements

WiX version 3.5 requires DotNet 2sp2, or DotNet 3.5sp1, or DotNet 4. Without DotNet, or with older versions, it spits out error messages, that don't tell what's wrong. It doesn't automatically install DotNet, nor does it say that it needs it - although it comes with an example, that shows how installers can do this.

If you have Windows-7, then you already have DotNet 3.5 installed.

Wix 3.7 needs DotNet 4. With older versions it just says that it needs DotNet, but doesn't tell which version it needs. And you must have KB931125 installed, otherwise the install will just fail, without giving a reason.

Install

If the installer opens a warning window titled 'Prerequisites', which says that Votive is missing: just click on OK, it's not required.

If you have just installed WiX, but it doesn't work, then probably the environment variable %WIX% isn't yet set, so you must logout and login, or reboot.

Use

WiX does not have a graphic user interface, it is purely command line oriented. It consists of several separate programs with strange names (examples: candle, light, heat), each one does some part of the job, they must be run in the correct sequence, and with the right parameters and config files.

The config files must be XML-files, created with a plain text editor. The syntax is horrible and full of exceptions that defy any logic, the help files are full of huge alphabetic lists of options, and badly lack examples.

In addition to the WiX syntax, you also need a lot of knowledge about how Windows Installer internally works (very complex), see msi.chm.

WiX doesn't add its directory to %PATH%. Instead it creates the environment variable %WIX%, that contains its path, including a trailing backslash, but without 'bin'. So you must usually add 'bin' to the contents of that environment variable, and you should put everything in double quotes in case the path contains a blank. Here is a sample command line from one of my scripts:
"%WIX%bin\light.exe" firefox.wixobj files.wixobj keys.wixobj -o Firefox.msi -b "%srcpath%" -sacl

Alternative

An alternative software with graphic user interface is Advanced Installer. A lot easier to use, but also very powerful.

Hints

There are two methods to define 'install per machine only':
<Package InstallScope="perMachine">
<Property Id="ALLUSERS" Value="1"/>

If you want to use WiX to install an EXE-file as service, there is no tag in ServiceInstall to declare which of the files should run as service. Instead put <ServiceInstall> into the same component as the <File> tags, then write KeyPath="yes" in the declaration of the file that should run as service, and KeyPath="no" in all other files, or put only the service.exe into the component. This selection is absolutely not what KeyPath is normally meant for, but in this case it's used this way. This is probably not a feature of WiX, but of Windows Installer, probably documented somewhere in msi.chm.

Heat can convert from registry files to xml files. Except files that contain the correct syntax to remove a value. Heat doesn't understand that. Also the docs say it can read either version 4 or version 5 registry file. But if it reads from version 4, it garbles umlaut characters like ä. Convert the reg file from ansi to unicode before heat processes it. And don't forget to insert the optional byte order mark in the first two bytes of the file, here they are not optional.

You will need a lot of Google searches. If the search results contain an entry from StackOverflow, read that one first, or directly search there, because these are usually the best ones for really difficult questions.