Compile-time variables
WiX lets you specify variables that are evaluated at compile time. You might use this to get environmental variables from the build machine, get the directory where your source files are, or access custom variables you've set up in a separate WiX include file (.wxi
).
WiX has three classifications for preprocessor variables: Environment, System, and Custom. We'll discuss each in the following sections.
Environment variables
Environment variables are set in the environment where the build process is running, usually from the command prompt. The following command sets an environment variable called myVar
to the value myvalue
:
set myVar=myvalue
To pass this to your project, build your .wxs
files from the same command window using Candle. Now access the environment variable in your WiX markup by using a dollar sign and parentheses, prefixing the variable name with env
. Here's an example:
<Property Id="property1" Value="$(env.myVar)" />
System variables
System variables...