Book Image

WiX Cookbook

By : Nicholas Matthew Ramirez
1 (1)
Book Image

WiX Cookbook

1 (1)
By: Nicholas Matthew Ramirez

Overview of this book

Table of Contents (20 chapters)
WiX Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a C# custom action and referencing it in your project


In this recipe, we'll see how to create a C# custom action that does something simple: get the computer's time zone and store it in a WiX property. Often, we need to collect information like this and either present it on the GUI or use it behind the scenes to make some decisions later when the computer is modified.

Windows installer doesn't know how to use a C# custom action directly. It only understands unmanaged code. However, WiX comes with a library called Deployment Tools Foundation (DTF) that bridges the gap. The C# custom action project template that's installed in Visual Studio with the WiX toolset starts out with a reference to the Microsoft.Deployment.WindowsInstaller assembly. That's DTF.

The convention is to have a data-driven approach to custom actions. During the installation sequence (or the immediate phase of the execute sequence), you can collect information and set properties with it. Then, during the deferred...