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, ...

Get WiX 3.6: A Developer's Guide to Windows Installer XML now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.