This simple WiX tutorial teaches you how to use Windows Installer XML(WiX) to create an installer MSI from scratch.
1. Download Windows Installer XML Toolset
WiX is an open source project, originally developed by Microsoft. You can download the binary and source code from Sourceforge. Navigate to http://sourceforge.net/projects/wix.
- Download the latest WiX toolset binary and source code package.
- Create a folder on your local driver, like c:\WiX.
- Unzip the downloaded file into the folder you just created: c:\WiX.
- Go to c:\WiX, you will see WiX compiler: candle.exe, WiX linker: light.exe, and some other files.
- Refer to the WiX.chm for WiX Schema, help and documentations.
Take a look at the available elements from the WiX schema in the WiX Help file (under the WiX Help | Authoring | Wix Schema node). As you can see, with over 230 elements available, there is some complexity associated with creating installers. The good news is that you typically only need to use a small subset of these elements when creating an installer.
2. Create Your First WiX File
Create an xml file: product.wxs (copied from wix.chm) as below
This WiX file will create an MSI file to copy readme.txt into %sysdrv%/program files/test program/
<?xml version='1.0'?>
<WiX xmlns='http://schemas.microsoft.com/wix/2003/01/wi'>
<Product Id='12345678-1234-1234-1234-123456789012' Name='Test Package' Language='1033'
Version='1.0.0.0' Manufacturer='Microsoft Corporation'>
<Package Id='12345678-1234-1234-1234-123456789012'
Description='My first Windows Installer package'
Comments='This is my first attempt at creating a Windows Installer database'
Manufacturer='Microsoft Corporation' InstallerVersion='200' Compressed='yes' />
<Media Id='1' Cabinet='product.cab' EmbedCab='yes' />
<Directory Id='TARGETDIR' Name='SourceDir'>
<Directory Id='ProgramFilesFolder' Name='PFiles'>
<Directory Id='MyDir' Name='TestProg' LongName='Test Program'>
<Component Id='MyComponent' Guid='12345678-1234-1234-1234-123456789012'>
<File Id='readme' Name='readme.txt' DiskId='1' src='readme.txt' />
</Component>
</Directory>
</Directory>
</Directory>
<Feature Id='MyFeature' Title='My 1st Feature' Level='1'>
<ComponentRef Id='MyComponent' />
</Feature>
</Product>
</WiX>
3. Play It with Candle and Light
Candle is the compiler used to compile the XML documents to object files that contain symbols and references to symbols. Light is a linker takes one or more object files and links the references in the object files to the appropriate symbols in other object files. Light is also responsible for collecting all of the binaries, packaging them appropriately, and generating the final MSI or MSM file.
Now you can compile and link your WiX file.
- Compile it with WiX compiler - Candle:
c:\WiX\candle product.wxs
- Link wixobj with WiX Linker - Light:
c:\WiX\light product.wixobj
- Test your first MSI:
c:\WiX\msiexec /i product.msi