One of the most common reasons for using MSBuild with WiX project files is to integrate the build of an installer into an existing daily build process. This is often coupled with a need to build WiX projects without having to pre-install any WiX tools on the daily build machine. WiX projects and the WiX toolset to build them can be added to most daily build processes that support MSBuild using a few simple steps.
To avoid having to install WiX on build machines you can check all the tools necessary to build WiX projects into your source code control system. Here's how:
The actual file locations in steps 3 and 4 will vary depending on where you chose to install WiX. On 64-bit operating systems the files will be located under c:\Program Files (x86).
After checking the WiX tools into source code control the .wixproj file must be modified to point to the location of the checked in tools. Open the .wixproj file in any text editor, such as Visual Studio, and add the following to the file anywhere between the <Project> element before the <Import> element:
<PropertyGroup> <WixToolPath>$(SourceCodeControlRoot)\wix\3.0.4311.0</WixToolPath> <WixTargetsPath>$(WixToolPath)\Wix.targets</WixTargetsPath> <WixTasksPath>$(WixToolPath)\wixtasks.dll</WixTasksPath> </PropertyGroup>
The WixToolPath must be set to point to the location of the WiX tools directory created in Step 1. The method used to reference the location will vary depending on your build system, but it can either be a relative path to the directory (such as ..\..\tools), an MSBuild property that is set via an environment variable (such as $(BinariesRoot) in a Team Foundation Server build) or a custom property passed in on the command-line or via an environment variable.
The WixTargetsPath and WixTasksPath properties direct MSBuild to use the WiX build process and WiX tasks from the tools directory.