Using project references in WiX
For those who don’t know it yet: you can use project references in your WiX installer project and use these inside the WXS files!
In the example below I’ve added a reference from the Setup project to the Program project.
Look at the lines 12 and 13 where I use project reference variables to point to the output location and the output file name:
1: <?xml version="1.0" encoding="UTF-8"?>
2: <Wix >="http://schemas.microsoft.com/wix/2006/wi">
3: <Product Id="YOURGUIDHERE" Name="Setup" Language="1033" Version="1.0.0.0" Manufacturer="Setup" UpgradeCode="YOURGUIDHERE">
4: <Package InstallerVersion="200" Compressed="yes" />
5:
6: <Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
7:
8: <Directory Id="TARGETDIR" Name="SourceDir">
9: <Directory Id="ProgramFilesFolder">
10: <Directory Id="INSTALLLOCATION" Name="MyProject">
11: <Component Id="ProductComponent" Guid="YOURGUIDHERE">
12: <File Name="$(var.Program.TargetFileName)"
13: Source="$(var.Program.TargetPath)" />
14: </Component>
15: </Directory>
16: </Directory>
17: </Directory>
18:
19: <Feature Id="ProductFeature" Title="Setup" Level="1">
20: <ComponentRef Id="ProductComponent" />
21: </Feature>
22: </Product>
23: </Wix>
The sweet thing about this is that it nicely integrates with TeamBuild! You don’t have to worry about the actual location of included items. Even resource files that are not part of the output can be referred to by using the solution directory variable. All available project reference variables can be found in the documentation.
The only problem I’ve discovered yet when referencing multiple projects with the same name…