Complete list of Candle preprocessor variables
Some people have asked about this in the past on the wix-users mailing list, so I thought I'd just put it here so it's on the web searches. (We really need to do an overhaul on our WiX home page).
This is just copied verbatim from the Wix.chm file.
[Edit]: By the way, this list applies to Votive v3 and not Votive v2. Although similar, complete instructions on how to do this in Votive v2 are given in Rob's MSDN article here (https://msdn2.microsoft.com/en-us/aa302186.aspx#wixsetup_topic9).
Project References
Introduction
The WiX Visual Studio package supports adding project references to a WiX project. This ensures that build order dependencies are defined correctly within the solution. In addition, it generates a set of WiX preprocessor definitions which are set on the Candle command line and can be referenced in source files.
Adding Project References
To add a project reference to a WiX project:
- Right-click on the References node of the project in the Solution Explorer and choose Add Reference...
- In the Add WiX Library Reference dialog, click on the Projects tab.
- Select the desired project(s) and click the Add button, then click OK to dismiss the dialog.
List of Supported Project References
The WiX Visual Studio package supports the following project reference variables:
Variable name |
Example usage |
Example value |
var.<ProjectName>.Configuration |
$(var.MyProject.Configuration) |
Debug or Release |
var.<ProjectName>.FullConfiguration |
$(var.MyProject.FullConfiguration) |
Debug | AnyCPU |
var.<ProjectName>.Platform |
$(var.MyProject.Platform) |
AnyCPU, Win32, x64 or ia64 |
var.<ProjectName>.ProjectDir |
$(var.MyProject.ProjectDir) |
C:\users\myusername\Documents\Visual Studio 2005\Projects\MyProject\ |
var.<ProjectName>.ProjectExt |
$(var.MyProject.ProjectExt) |
.csproj |
var.<ProjectName>.ProjectFileName |
$(var.MyProject.ProjectFileName) |
MyProject.csproj |
var.<ProjectName>.ProjectName |
$(var.MyProject.ProjectName) |
MyProject |
var.<ProjectName>.ProjectPath |
$(var.MyProject.ProjectPath) |
C:\users\myusername\Documents\Visual Studio 2005\Projects\MyProject\MyApp.csproj |
var.<ProjectName>.TargetDir |
$(var.MyProject.TargetDir) |
C:\users\myusername\Documents\Visual Studio 2005\Projects\MyProject\obj\Debug\ |
var.<ProjectName>.TargetExt |
$(var.MyProject.TargetExt) |
.exe |
var.<ProjectName>.TargetFileName |
$(var.MyProject.TargetFileName) |
MyProject.exe |
var.<ProjectName>.TargetName |
$(var.MyProject.TargetName) |
MyProject |
var.<ProjectName>.TargetPath |
$(var.MyProject.TargetPath) |
C:\users\myusername\Documents\Visual Studio 2005\Projects\MyProject\obj\Debug\MyProject.exe |
var.SolutionDir |
$(var.SolutionDir) |
C:\users\myusername\Documents\Visual Studio 2005\Projects\MySolution\ |
var.SolutionExt |
$(var.SolutionExt) |
.sln |
var.SolutionFileName |
$(var.SolutionFileName) |
MySolution.sln |
var.SolutionName |
$(var.SolutionName) |
MySolution |
var.SolutionPath |
$(var.SolutionPath) |
C:\users\myusername\Documents\Visual Studio 2005\Projects\MySolution\MySolution.sln |
Example
The following File element demonstrates how to use project references in WiX authoring:
<File Id="MyExecutable" Name="$(var.MyProject.TargetFileName)" Source="$(var.MyProject.TargetPath)" DiskId="1" />
Comments
Anonymous
January 29, 2008
PingBack from http://msdnrss.thecoderblogs.com/2008/01/29/complete-list-of-candle-preprocessor-variables/Anonymous
January 31, 2008
If I follow the add-reference instructions above, I get a dialog saying "Sorry, project references are not yet supported in Votive. If you want to add the code, by all means! :)" Votive 2.0.5325 If I right-click the project itself and choose Project Dependencies, all of the right dependencies are already listed; unfortunately, that doesn't seem to connect to these variable definitions. I presume this is a 3.0-only thing? Thanks MarkAnonymous
January 31, 2008
Mark, This should also work in Votive 2.0, although the preprocessor definitions may be slightly different than the ones I presented here. Take a look at Rob's MSDN article here (http://msdn2.microsoft.com/en-us/aa302186.aspx#wixsetup_topic9) for more information on how to do this in Votive 2.0. Sorry about the confusion. I should have pointed this out in the blog entry.Anonymous
February 13, 2008
We have a problem with adding Project References when the project resides in a Visual Studio 2008 solution folder. The FullPath return "objecr ref not instance of an object" and we can't access the project vars in any scripts. Moving project to the solution root fixes the problem. Moving it back breaks it again CliffAnonymous
February 25, 2008
What does "MyProject" mean in this example: "$(var.MyProject.Configuration) "? I have "Infrastructure.Module" project (created by SCSF, CAB franework). When I use it like this - $(var.Infrastructure.Module.Configuration) I got compile error - error CNDL0150: Undefined preprocessor variable '$(var.Infrastructure.Module.Configuration)' Thank you.Anonymous
February 25, 2008
Eugene, Although there could be a bug (there's an embedded period), I think that perhaps you haven't added the other project as a project reference in Votive? This feature won't work unless you have added a project reference.Anonymous
February 26, 2008
The comment has been removedAnonymous
February 26, 2008
I installed 3.0.3815.0 and "$(var.Infrastructure.Module.Configuration)” works (although when I select "Infrastructure.Module" in Solution Explorer, the "Full Path" field in Properties says: "Object reference not set to an instance of an object.")