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 compile-time (otherwise known as preprocessor) variables: Custom, Environment, and System. We'll discuss each in the following sections.
Custom compiler variables
To set your own compile-time variables, also known as preprocessor variables, use the <?define ?>
directive in your WiX markup:
<?define myVar = "myvalue" ?>
Although you can do this in any of your .wxs
files, it's common to do it in a separate include file (.wxi
) file, for which there is a Visual Studio template. The include files allow you to gather your preprocessor statements into a single place. At compile time, your variables will be inserted into your source files wherever you've referenced them...