Book Image

WiX 3.6: A Developer's Guide to Windows Installer XML

Book Image

WiX 3.6: A Developer's Guide to Windows Installer XML

Overview of this book

The cryptic science of Windows Installer can seem far off from the practical task of simply getting something installed. Luckily, we have WiX to simplify the matter. WiX is an XML markup, distributed with an open-source compiler and linker, used to produce a Windows Installer package. It is used by Microsoft and by countless other companies around the world to simplify deployments. "WiX 3.6: A Developer's Guide to Windows Installer XML" promises a friendly welcome into the world of Windows Installer. Starting off with a simple, practical example and continuing on with increasingly advanced scenarios, the reader will have a well-rounded education by book's end. With the help of this book, you'll understand your installer better, create it in less time, and save money in the process. No one really wants to devote a lifetime to understanding how to create a hassle-free installer. Learn to build a sophisticated deployment solution targeting the Windows platform in no time with this hands-on practical guide. Here we speed you through the basics and zoom right into the advanced. You'll get comfortable with components, features, conditions and actions. By the end, you'll be boasting your latest deployment victories at the local pub. Once you've finished "WiX 3.6: A Developer's Guide to Windows Installer XML", you'll realize just how powerful and awesome an installer can really be.
Table of Contents (23 chapters)
WiX 3.6: A Developer's Guide to Windows Installer XML
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 for Microsoft.Tools.WindowsInstallerXml. Next, add a class that extends the WixExtension class. Here, we've called it MyWixExtension:

using Microsoft.Tools.WindowsInstallerXml;

namespace MyPreprocessorExtension
{
   public class MyWixExtension...