WiX, or Windows Installer XML Toolset, is the first open-source project released by Microsoft. With this tool you can build Windows Installer packages by using the XML format. This does not have a GUI (Graphical User Interface), everything you do is from XML and command line. It is a tool designed specifically for IT Pros who know what they are doing, but it’s very powerful. WIX was released back in 2004 and this was used to package the old Office 2007, SQL Server 2005 and Visual Studio 2005/2008 packages.
In these series of tutorials we will go through multiple topics regarding how to add files, shortcuts, registry, and more.
How to install
In this first tutorial, let’s see how we first get WiX and how to create a basic empty MSI.
First, let’s download WiX from here. The version available when this tutorial is written is 3.11.1.
After WiX is downloaded, double-click the installer (in our case wix311.exe) and install it with the default options. This will add all the files needed to work with WIX in %ProgramFiles(x86)\WiX Toolset v3.11\.
That’s it, you now have WiX installed on your machine. But no shortcut?
Yes, as previously mentioned, WiX does not offer any kind of GUI to work with. It’s time to start XMLing! (yes we invent words 🙂 )
To create a basic MSI, only with some information in it, we must first create a .wxs file. Create a folder on a desired location because we will need to place two files in it.
In the folder create a new empty text file and name it example1.wxs.
Paste the follwing in example1.wxs
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <Product Id="*" UpgradeCode="12345678-1111-2222-3333-666666666666" Name="My First Installer" Version="188.8.131.52" Manufacturer="My Company" Language="1033"> <Package InstallerVersion="200" Compressed="yes" Comments="Hello, this is my first installer"/> </Product> </Wix>
So what are we doing here?
We are telling WiX that we want an MSI with a randomly generated Product ID, Upgrade Code will be 12345678-1111-2222-3333-666666666666, the Name will be My First Installer, the MSI ProductVersion is 184.108.40.206, Language is English (1033) and we add the Manufacturer My Company and some comments. That’s it! No other data will be added in the MSI.
Once we have the example.wxs created we must make besides it a new batch file. So create an make_msi.bat.
In the make_msi.bat paste the following:
"C:\Program Files (x86)\WiX Toolset v3.11\bin\candle.exe" example1.wxs "C:\Program Files (x86)\WiX Toolset v3.11\bin\light.exe" example1.wixobj @pause
In the end, your folder should look like this.
What are the lines in the batch file doing exactly?
The first line is targeting candle.exe, which is the WIX compiler. This generates an object file (bundle.wixobj) in your folder.
The second line is for light.exe, which is the WIX linker. This generates the final installer (MSI) based on the object (wixobj) created previously.
Once you have everything ready, double-click the make_msi.bat.
This should be a quick build and, in the end, the example1.msi appears in the folder.
Now that we have the MSI created, let’s open it with a more modern tool like Advanced Installer and see if we have everything that we asked WiX configured in it.
When we first open the MSI and check the Product Details, we see that the Product Name, Version and Published are set as desired. Also the Product Code is a random generated one and the Upgrade Code is the one mentioned in the XML.
And if we further check in the Summary Information, we can see that the rest of the settings have been added.
That is it for the first tutorial!
For more information and documentation about WiX, check out this page.