WiX Tool set
WiX is a set of tools that allows you to create Windows Installer-based deployment packages for your application. The WiX toolset is based on a declarative XML authoring model. You can use WiX on the command line by using the WiX tools or MSBuild. In addition, there is also a WiX Visual Studio plug-in that supports VS2005, VS2008, and VS2010. The WiX toolset supports building the following types of Windows Installer files:
- Installer (.msi)
- Patches (.msp)
- Merge Modules (.msm)
- Transforms (.mst)
WiX supports a broad spectrum of Windows Installer features. In addition, WiX also offers a set of built-in custom actions that can be used and incorporated in Windows Installer packages. The custom actions are offered in a set of WiX extensions. Some common WiX extensions include support for Internet Information System (IIS), Structured Query Language (SQL), the .NET Framework, Visual Studio, and Windows etc.
How does WiX work?
The WiX source code is written in XML format with a .wxs file extension. The WiX tools follow the traditional compile and link model used to create executables from source code. At build time, the WiX source files are validated against the core WiX schema, then processed by a preprocessor, compiler, and linker to create the final result. There are a set of WiX tools that can be used to produce different output types.
Project Templates
The WiX Visual Studio package provides the following Visual Studio project templates:
- WiX Project - used to create a new Windows Installer package (.msi) file. Each new WiX project includes a .wxs file that consists of a <Product> element that contains a skeleton with the WiX authoring required to create a fully functional Windows Installer package. The <Product> element includes <Package>, <Media>, <Directory>, <Component> and <Feature> elements.
- WiX Library Project - used to create a new WiX library (.wixlib) file. A .wixlib file is a library of setup functionality that can be easily shared across different WiX-based packages by including it when linking the setup package. Each new WiX library project includes a .wxs file that consists of an empty <Fragment> element that can be populated with WiX authoring that can be shared by multiple packages.
- WiX Merge Module Project - used to create a new Windows Installer merge module (.msm) file. A merge module contains a set of Windows Installer resources that can be shared by multiple Windows Installer installation packages by merging the contents of the module into the .msi package. Each new WiX merge module project includes a .wxs file that consists of a <Module> element that contains a skeleton with the WiX authoring required to create a fully functional merge module. The <Module> element includes <Package>, <Directory> and <Component> elements.
To create a new project:
- Click on File | New | Project on the Visual Studio menu.
- Navigate to the Windows Installer XML node.
- Select the project template and press OK
Project Property Pages
To access the WiX project property pages, right-click on a WiX project in the Visual Studio Solution Explorer and choose Properties. WiX projects contain the following property pages:
- Installer
- Build
- Build Events
- Paths
- Tool Settings
Installer Property Page
The Installer tab contains the following configurable options:
- Output name - a text box that contains the name of the file that will be created by the build process.
- Output type - a drop-down list that allows you to select the output type: An MSI package, merge module, WiX library, or bootstrapper.
Build Property Page
The Build tab contains the following configurable options:
- The General section allows you to define configuration-specific constants and specify the culture to build.
- The Messages section allows you to specify warning levels, toggle treating warnings as errors and verbose output.
- The Output section allows you to specify the output path, toggle delete temproary files, suppress output of the wixpdb file, and toggle whether or not to bind files into the library file (if it is a WiX Library project).
Build Events Property Page
The Build Events tab contains the following configurable options:
- Pre-build event command line - a text box that contains the pre-build events to execute before building the current project.
- Post-build event command line - a text box that contains the post-build events to execute after building the current project.
- Run the post-build event - a drop-down combo box that allows you to specify the conditions in which post-build events should be executed.
The Build Events tab contains buttons named Edit Pre-build... and Edit Post-build... that display edit dialogs for the pre and post-build event command lines. The edit dialogs contain a list of all valid WiX project reference variables and their values based on the current project settings.
Paths Property Page
The Paths tab contains the following configurable options:
- The Reference Paths section allows you to define paths you want to use when locating references (WiX extensions and WiX libraries).
- The Include Paths section allows you to define paths you want to use when locating WiX Include files.
Tool Settings Property Page
The Tool Settings tab contains the following configurable options:
- The ICE validation section allows you to toggle ICE validation suppression or specify which ICE validation to suppress.
- The Additional parameters section allows you to specify command line arguments to pass directly to the WiX tools at build time.
Creating a .wixproj File
In order to build WiX using MSBuild, a .wixproj file must be created. The easiest way to create a new .wixproj for your installer is to WiX in Visual Studio because it automatically generates standard msbuild project files that can be built on the command line by simply typing:
msbuild <projectfile>.wixproj
If you do not have Visual Studio available, a .wixproj file can be created using any text editor. The following is a sample .wixproj file that builds an installer consisting of a single product.wxs file. If you want to copy and paste this example, remember to change the <ProjectGuid> value to match your own.
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>3.0</ProductVersion>
<ProjectGuid>{c523055d-a9d0-4318-ae85-ec934d33204b}</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>WixProject1</OutputName>
<OutputType>Package</OutputType>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v[[Version.Major]].x\Wix.targets</WixTargetsPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>
<ItemGroup>
<Compile Include="Product.wxs" />
</ItemGroup>
<Import Project="$(WixTargetsPath)" />
</Project>
Additional .wxs files can be added using additional <Compile> elements within an ItemGroup. Localization files (.wxl) should be added using the <EmbeddedResource> element within an ItemGroup. Include files (.wxi) should be added using the <Content> element within an ItemGroup.
Comments
Post a Comment