The WiX 3.0 release candidate has just been released so lets have a look at it. After installing WiX, the linker and compiler are installed along with Visual Studio tools. Create a new WiX Project using the new WiX project type that has been installed.
A new wxs file will be created as below:
The Product section contains all the main elements for the installer, there can only be one product section in a wxs file. The Directory section is where files and other components are defined for installation. WiX doesn't specify how to install files, rather you define the structure you want, then WiX installs file based on that structure.
We will now make some changes to the wxs file and add some dummy files and a shortcut.
This code installs four files and sets a short cut too the first in the start menu.
The <Directory Id="TARGETDIR" Name="SourceDir"> line specifies a virtual directory. It contains the directory elements that defines the actual structure of the install. StartMenuFolder is defined so that the shortcut can reference it. ProgramFilesFolder is where the program will be installed. StartMenuFolder and ProgramFilesFolder are system folder properties defined by the Windows Installer engine. The system folders available are:
Components are small groups of files/registry settings/directories/shortcuts etc. They are the smallest unit that can be conditionally installed. Each Component must be specified in a Feature for it to be installed.
Inside the Component we have defined, there are specified four Files. Each File has a name and a source. The name can be different from the source file allowing WiX to rename at install time. File elements may contain Shortcut elements which as their name suggests install shortcuts. Alternatively shortcuts rather then being nested inside a file can have the target attribute set i.e Target="[#testFile1]". This allows you to create a shortcut in one component that points to a file in another component.
If we build the WXS file now we end up with a file called WixTest.msi. When we run this msi file, the four file will be installed to C:\Program Files\WixTest, and a shortcut will be cretaed in the start menu. If you look at add/remove programs WixTest will appear, and can be uninstalled from here.
So now we have an installer that will silently install several files and a shortcut. WiX provides a simple way to quickly build an installer that gets all the benefits of the Windows Installer framework. Future posts will cover adding a UI and interacting with the registry, SQL Server and XML files.