Creating your first WiX project

The Wix tools allow you to define the structure of a windows installer package using an XML file. This gives you all of the usual benefits of XML: easy editing with a variety of tools, the ability to modify the files using well-known technologies, and the ability to put the source file under source code control, for ex. the Wix tools themselves are command-line tools, so they fit well with almost any build process. In this post, we will look at creating a WiX project using Visual Studio.

A little note on MSi Engineering
Windows Installer setup package can be described as a three-level hierarchy. The product is at the top of that hierarchy. Users can interact with a Windows Installer setup package at the product level, as during a default or typical install, or they might interact with the setup package at the features level, as during a custom install. Developers, on the other hand, have to interact with the setup package at the component and individual resource level.

Packages are built from components. A component is a group of one or more related resources—files, shortcuts, registry entries, etc.

Components are grouped into features. A feature is a group of one or more components that are installed together. A component can belong to one or more features, but each component is installed only once on a give machine.

Every Windows Installer product, package, and component is identified internally by a unique GUID. The product code GUID remains constant for all releases within the same major version of a product. The package code GUID changes for each build that is released into the wild. The component code GUID changes according to the rules governing components.

For more information on Component Rules Click Here

Starting a WiX project in Visual Studio

Step 1: Launch Visual Studio, and create a new project.

Step 2: Select Setup Project, Windows Installer XML Section

Step 3: Your first Wix Script and template is ready, you will get intuitive help when you start typing – Thanks to Votive

Explaining WiX script Elements

The product element defines the product that the installer will install. The name of the element corresponds to a table in the windows installer database, and the attributes correspond to the columns in the table. For instance, the installer database includes foreign key columns to relates many tables, while the WiX source files use nesting to accomplish the same relation. The WiX tools take care of defining the appropriate foreign key values for you.

–Package Id=”6697CCC3-B351-4DCE-820E-DEAC87F57A2A” Comments=”Demo Installer” Manufacturer=”” InstallerVersion=”200″ Languages=”1033″ Compressed=”yes”

Within the product element, you’ll find a single package element, defining the package that corresponds to this WiX file.

–Media Id=”1″ EmbedCab=”yes” Cabinet=””

The media element defines the distribution media where the MSI file and any associated CAB files will be stored.

The directory elements define the hierarchy of directories that the installer service will use with this software. Note that the Id attributes are not completely arbitrary. The windows installer defines a number of special directories, including the two (the program files folder and the program menu folder) that I’m using in this example.

The Component elements and their child elements define the exact software that will be installed. In this case, the first component consists of a single file, while the second includes a file and a shortcut to the file. Note that WiX will look for the files that you include relative to the XML file. The best plan is probably to place the XML file in the same folder as your source files, and place the wix tools on your path.

The feature element defines both the single feature in this package and the mapping between features and components.

One will need both the Windows Installer SDK and the WiX documentation to develop Wix Scripts and MSis.