For starters, what is WiX? WiX technology (Windows Installer XML) is a set of tools and specifications that simplify the process of creating distributions based on MSI (Microsoft Installer). If it is easier to explain, this is a wrapper around MSI with a human face.
In my opinion, the easiest way to learn is through simple examples. In this article I will give an example of the simplest installer.
To begin with, we set the conditions of the problem - it is necessary to create an installation distribution kit, which will contain the following dialogs:
')
Greeting
License agreement
Directory selection
Installation start
To create a distribution we need WiX itself, the latest version of which can always be downloaded at
Source Forge . At the moment the latest version is 3.5.0828.0.
It is necessary to download and install:
1.
ProjectAggregator2.msi - is needed in order to install Votive (located inside distribution kit number 2). Which, in turn, is an add-on for Visual Studio that facilitates the process of working with WiX (syntax highlighting, IntelliSense).
2.
Wix35.msi or
Wix35_x64.msi (depending on the platform)
3.
Russian language fileSo, downloaded, installed, run Visual Studio. File menu -> New Project, if everything is installed correctly - a new section Windows Installer XML has appeared. Select the project Project Setup Project, enter the name of the project (I left as it is SetupProject1).

The project will consist of a single Product.wxs file with which we will work. In my case, the file looked like this:
<? xml version ="1.0" encoding ="UTF-8" ? >
< Wix xmlns ="http://schemas.microsoft.com/wix/2006/wi" >
< Product Id ="b7bc7c6f-9a4e-4973-be84-eca8e3427c97" Name ="SetupProject1" Language ="1033" Version ="1.0.0.0" Manufacturer ="SetupProject1" UpgradeCode ="06a81104-1e30-463d-87e1-e8a79b4c682a" >
< Package InstallerVersion ="200" Compressed ="yes" />
< Media Id ="1" Cabinet ="media1.cab" EmbedCab ="yes" />
< Directory Id ="TARGETDIR" Name ="SourceDir" >
< Directory Id ="ProgramFilesFolder" >
< Directory Id ="INSTALLLOCATION" Name ="SetupProject1" >
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
<!-- <Component Id="ProductComponent" Guid="b11556a2-e066-4393-af5c-9c9210187eb2"> -->
<!-- TODO: Insert files, registry keys, and other resources here. -->
<!-- </Component> -->
</ Directory >
</ Directory >
</ Directory >
< Feature Id ="ProductFeature" Title ="SetupProject1" Level ="1" >
<!-- TODO: Remove the comments around this ComponentRef element and the Component above in order to add resources to this installer. -->
<!-- <ComponentRef Id="ProductComponent" /> -->
</ Feature >
</ Product >
</ Wix >
* This source code was highlighted with Source Code Highlighter .
To begin with we will adjust appearance and we will add support of Russian.Let's start with the addition of the Russian language. For this:
1. In the Product key, change 1033 to 1049
2. In the project properties (
right-click on the project name in Solution Explorer -> Properties ), the Build tab, insert ru-RU into the Cultures to build field
3. Add to the project (
right-click on the project name in Solution Explorer -> Add -> Existing Item ) the file WixUI_ru-ru.wxl (from the archive WixUI_ru-ru.v3.zip)
There is no dialog box in the generated project. There are two options for adding dialogs - create them yourself, or use a ready-made set of dialog boxes.
We will go the second way, to begin acquaintance better with a simple one. To do this, add a link to WixUIExtension.dll (
right- click on
the project name in Solution Explorer -> Add Reference - open the folder where WiX was installed, bin subdirectory )
The link was added, we specify which set we will use, at the end of the Product section we add
< Property Id ="WIXUI_INSTALLDIR" Value ="INSTALLLOCATION" ></ Property >
< WixVariable Id ="WixUILicenseRtf" Overridable ="yes" Value ="License.rtf" />
< UIRef Id ="WixUI_InstallDir" />
* This source code was highlighted with Source Code Highlighter .
WixVariable Id = “WixUILicenseRtf ” - points to the path to the license file (it wasn’t a question of it yet, added at once so that it wouldn’t be walked twice).
WixUI_InstallDir is a ready-made set of dialog boxes. This kit includes all the dialogs we need. In addition to it, there are also sets of WixUI_Advanced, WixUI_Mondo, WixUI_FeatureTree, WixUI_InstallDir, WixUI_Minimal.
Preparations are finished, you can start editing the installation file. For a start, let's see what the studio nagenerila:
Product key - describes the properties of the product.
Id - product identifier, unique GUID.
Name - product name
Language - installation package language
Version - product version
Manufacturer - the manufacturer
UpgradeCode - Unique GUID
To simplify your life, we define some variables. For what - the name of the product, for example, may occur more than once in the script, if we want to change it, we will have to look for it throughout the script and change it to a new one. To avoid this, we define a variable that will contain the name of the product and, if necessary, we will only change it. Above the
Product section add:
<? define ProductName ="SetupProject1" ? >
<? define ProductVersion ="1.0.0.0" ? >
<? define ProductCode ="b7bc7c6f-9a4e-4973-be84-eca8e3427c97" ? >
<? define UpgradeCode ="06a81104-1e30-463d-87e1-e8a79b4c682a" ? >
<? define Manufacturer ="MyCompany" ? >
* This source code was highlighted with Source Code Highlighter .
Now let's replace the value of the
Product key parameters with variables:
< Product Id ="$(var.ProductCode)" Name ="$(var.ProductName)" Language ="1049" Version ="$(var.ProductVersion)" Manufacturer ="$(var.Manufacturer)" UpgradeCode ="$(var.UpgradeCode)" >
* This source code was highlighted with Source Code Highlighter .
Now we decide on where we will install our product.
Directory key - determines the path for installation.
Directory Id = "TARGETDIR" is the root element for all folders that will be used to install the project.
Directory Id = "ProgramFilesFolder" folder Program Files (as indicated by Id = "ProgramFilesFolder").
Directory Id = "INSTALLLOCATION" folder named SetupProject1 in the Program Files folder. Immediately replace Name = "SetupProject1" with Name = "$ (var.ProductName)"
Add files to the installation package. To do this, first add the installable components. Following the advice “Remove the comments around this Component”, remove the comments from the Component inside the target folder and add, for example, a calculator.
< Component Id ="ProductComponent" Guid ="b11556a2-e066-4393-af5c-9c9210187eb2" >
< File Id ='Calc' DiskId ='1' Source ='C:\WINDOWS\system32\calc.exe' />
</ Component >
* This source code was highlighted with Source Code Highlighter .
Installing a component is impossible without including it in one of the Feature (to
be honest, not sure how in this case you can translate this term into Russian ). This element can be used when we need to give the user a choice of what to install and what not. In the context of our task, nothing was said about the possibility of choice, but despite this we need to bind the described Component to a single Feature:
< Feature Id ="ProductFeature" Title ="$(var.ProductName)" Level ="1" >
< ComponentRef Id ="ProductComponent" />
</ Feature >
* This source code was highlighted with Source Code Highlighter .
It remains to add a shortcut to the Start menu.
First, we indicate that we are going to work with the Start menu folder and want to create a folder with the name of our program containing a shortcut to the calculator.
In the Directory Id = "TARGETDIR" section, somewhere at the end we add:
< Directory Id ="ProgramMenuFolder" >
< Directory Id ="ApplicationProgramsFolder" Name ="$(var.ProductName)" >
< Component Id ="ApplicationShortcutCalc" Guid ="4CEBD68F-E933-47f9-B02C-A4FC69FDB551" >
< Shortcut Id ="ShortcutCalc"
Name ="Calc"
Description ="$(var.ProductName)"
Target ="[INSTALLLOCATION]Calc.exe"
WorkingDirectory ="INSTALLLOCATION" />
< RemoveFolder Id ="ApplicationProgramsFolder" On ="uninstall" />
< RegistryValue Root ="HKCU" Key ="Software\$(var.Manufacturer)\$(var.ProductName)" Name ="installed" Type ="integer" Value ="1" KeyPath ="yes" />
</ Component >
</ Directory >
</ Directory >
* This source code was highlighted with Source Code Highlighter .
We start to understand:
Directory Id = “ProgramMenuFolder” - points to the directory that contains the Start menu shortcuts.
Directory Id = "ApplicationProgramsFolder" - a folder of our program in the Start menu
Component - the component that contains the shortcut (remember to include it in the Feature)
Shortcut - actually a shortcut to the calculator
The final version of the file should look like this:
<? xml version ="1.0" encoding ="UTF-8" ? >
< Wix xmlns ="http://schemas.microsoft.com/wix/2006/wi" >
<? define ProductName ="SetupProject1" ? >
<? define ProductVersion ="1.0.0.0" ? >
<? define ProductCode ="b7bc7c6f-9a4e-4973-be84-eca8e3427c97" ? >
<? define UpgradeCode ="06a81104-1e30-463d-87e1-e8a79b4c682a" ? >
<? define Manufacturer ="MyCompany" ? >
< Product Id ="$(var.ProductCode)" Name ="$(var.ProductName)" Language ="1049" Version ="$(var.ProductVersion)" Manufacturer ="$(var.Manufacturer)" UpgradeCode ="$(var.UpgradeCode)" >
< Package InstallerVersion ="200" Compressed ="yes" />
< Media Id ="1" Cabinet ="media1.cab" EmbedCab ="yes" />
< Directory Id ="TARGETDIR" Name ="SourceDir" >
< Directory Id ="ProgramFilesFolder" >
< Directory Id ="INSTALLLOCATION" Name ="$(var.ProductName)" >
< Component Id ="ProductComponent" Guid ="b11556a2-e066-4393-af5c-9c9210187eb2" >
< File Id ='Calc' DiskId ='1' Source ='C:\WINDOWS\system32\calc.exe' />
</ Component >
</ Directory >
</ Directory >
< Directory Id ="ProgramMenuFolder" >
< Directory Id ="ApplicationProgramsFolder" Name ="$(var.ProductName)" >
< Component Id ="ApplicationShortcutCalc" Guid ="4CEBD68F-E933-47f9-B02C-A4FC69FDB551" >
< Shortcut Id ="ShortcutCalc"
Name ="Calc"
Description ="$(var.ProductName)"
Target ="[INSTALLLOCATION]Calc.exe"
WorkingDirectory ="INSTALLLOCATION" />
< RemoveFolder Id ="ApplicationProgramsFolder" On ="uninstall" />
< RegistryValue Root ="HKCU" Key ="Software\$(var.Manufacturer)\$(var.ProductName)" Name ="installed" Type ="integer" Value ="1" KeyPath ="yes" />
</ Component >
</ Directory >
</ Directory >
</ Directory >
< Feature Id ="ProductFeature" Title ="SetupProject1" Level ="1" >
< ComponentRef Id ="ProductComponent" />
< ComponentRef Id ="ApplicationShortcutCalc" />
</ Feature >
< Property Id ="WIXUI_INSTALLDIR" Value ="INSTALLLOCATION" ></ Property >
< WixVariable Id ="WixUILicenseRtf" Overridable ="yes" Value ="License.rtf" />
< UIRef Id ="WixUI_InstallDir" />
</ Product >
</ Wix >
* This source code was highlighted with Source Code Highlighter .
We do Build, we start, we check result.
Where to read
Project pageAlex Shevchuk: From MSI to WiX (mostly in English, but there is some in Russian)
WiX TutorialwixwikiContinued
Part 2 - Fragments and Includes