Preprocessor extensions

You can create your own variable prefixes (remember var, env, and sys?) and even call C# methods at compile time by writing a preprocessor extension. You'll need to make a new C# class library. We'll walk through each step and then look at the complete code afterwards.

Understand that a preprocessor extension is only executed during compilation to insert data into your WiX markup. So, the end user of your installer will never see it. Also, a preprocessor extension is different than extensions such as WixUIExtension, which are technically compiler extensions. We'll get to make a compiler extension later in the book.

First, in your new class library, add a reference to Wix.dll from the WiX bin directory, and add a using statement ...

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.