Reading the Default WiX Project Template
Once a WiX project is created, it creates file contains the beginning of the setup code for the project. Everything needed to create an MSI can be added to this file.
Note: If you are not familiar with Windows Installer setup packages, you are strongly encouraged to review the MSDN documentation about the Installation Package before continuing. It will provide a lot of valuable context as we dig into the details of a Windows Installer setup package.
<?xml version="1.0" encoding="UTF-8"?> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <Product Id="677a7ac3-6e9b-4531-8a61-c31acc301d27" Name="MySetup" Language="1033" Version="1.0.0.0" Manufacturer="MySetup" UpgradeCode="ae949a2b-1fcd-4abe-bf47-1eb923575de1"> <Package InstallerVersion="200" Compressed="yes" /> <Media Id="1" Cabinet="MySetup.cab" EmbedCab="yes" /> <Directory Id="TARGETDIR" Name="SourceDir"> <Directory Id="ProgramFilesFolder"> <Directory Id="INSTALLLOCATION" Name="MySetup"> <!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. --> <!-- <Component Id="ProductComponent" Guid="78576f70-ac55-4d9c-b9e8-a96d81889ada"> --> <!-- TODO: Insert files, registry keys, and other resources here. --> <!-- </Component> --> </Directory> </Directory> </Directory>
<Feature Id="ProductFeature" Title="PUT-FEATURE-TITLE-HERE" Level="1"> <ComponentRef Id="ProductComponent" /> </Feature> </Product> </Wix>
If you are familiar with the Windows Installer, the structure of the .wxs file should be familiar. First, the Wix element exists purely to wrap the rest of the content in the file. The Wix element also specifies the namespace, the xmlns attribute that enables validation during compile and auto-complete in Visual Studio via IntelliSense. Next, the Product element defines the required Windows Installer properties used to identify the product, such as the ProductCode, ProductName, ProductLanguage, and ProductVersion. Third, the Package element contains the attributes for the Summary Information Stream that provides information about the setup package itself. The rest of the elements, except the ComponentRef element, map to Windows Installer tables by the same name, for example the Media table, Directory table, Component table, and Feature table. The ComponentRef element is used to tie the Features to their Components which maps to the entries in the FeatureComponents table.
The default template that is generated when you create a new WiX project will generates a build warning. In the Output window, you may see this warning:
The cabinet 'MySetup.cab' does not contain any files. If this installation contains no files, this warning can likely be safely ignored. Otherwise, please add files to the cabinet or remove it.
Because the WiX project does not yet reference an application, there is nothing to install. Once a file is added to the installer, this warning will go away.