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

Preface

Since Rob Mensching offered up the WiX toolset as the first open source project from Microsoft in 2004, it has been quietly gaining momentum and followers. Today, thousands use it to build Window Installer packages from simple XML elements. Gone are the days when you would have had to pay for software to build an installer for you. Now, you can do it yourself for cheap.

Not only that, but WiX has matured into a fairly slick product that's sufficiently easy to use. Best of all, it has the bells and whistles you want, including functionality to add user interface wizards, Start menu shortcuts, control Windows services, and read and write to the registry.

This new edition, WiX 3.6: A Developer's Guide to Windows Installer XML, brings you up-to-date on the latest changes to the toolset. Whether you're new to WiX or an established pro, you're likely to find new insights. Each chapter gets straight to the point, giving you hands-on experience, so you'll master the technology quickly.

What this book covers

Chapter 1, Getting Started, explains how after downloading and installing the WiX toolset, you'll start using it right away to create a simple installer. Then, you'll see how to add a basic user interface to it, install it with logging turned on, and view its internal database.

Chapter 2, Creating Files and Directories, gives you a deeper understanding of how files are installed and the best way to organize them in your project. You'll then use the tool Heat.exe to generate WiX markup. Last, you'll learn about copying and moving files, and installing special-case files.

Chapter 3, Putting Properties and AppSearch to Work, introduces you to Windows Installer properties, including those that are defined automatically and those that are invented by you. Afterwards, you'll check the end user's computer for specific files, directories, registry keys, and INI file settings using AppSearch.

Chapter 4, Improving Control with Launch Conditions and Installed States, teaches you to leverage conditional statements to set prerequisites for running your installer or to exclude particular features or components from the install. You'll also discover how to check the action state and installed state of your features and components.

Chapter 5, Understanding the Installation Sequence, gives you a clear picture of how the whole installation process works as you examine the order and meaning of installer actions. You will then create custom actions and add them to this built-in sequence. Then, you'll learn the basics of using the Deployment Tools Foundation library for writing custom action code in C#.

Chapter 6, Adding a User Interface, after giving you a quick introduction to the standard dialogue wizards that come with the WiX toolset, shows how to build your own from scratch. You'll learn all of the required elements for displaying dialogs and linking them together. You'll also see how to display common messages such as errors and cancellation confirmations.

Chapter 7, Using UI Controls, gives you hands-on experience with each type of UI control including buttons, textboxes, and progress bars.

Chapter 8, Tapping into Control Events, breathes life into your UI controls by having them publish and subscribe to events. We'll get details on what each event does and take a closer look at those you'll use on a routine basis.

Chapter 9, Working from the Command Line, emphasizes the fact that we don't particularly need Visual Studio to compile our projects. We'll cover the commands necessary to build an installer from the command line using Candle.exe, our compiler, and Light.exe, our linker/binder. We will also explore how to use preprocessor statements and how to create a custom preprocessor extension.

Chapter 10, Accessing the Windows Registry, illustrates how our installer may read and write to the Windows Registry. We'll add and remove keys, copy values, and set permissions.

Chapter 11, Controlling Windows Services, provides some solid examples for installing and interacting with Windows services. You'll see how to set the service's user account, add service dependencies, and set failure recovery.

Chapter 12, Localizing Your Installer, tackles how to render your UI for different languages and how Light.exe, the WiX linker, plays a role. You'll then get involved in making a single multi-language installer.

Chapter 13, Upgrading and Patching, covers the all-so-important topic of upgrading and patching. You'll get the low down on major upgrades, minor upgrades, and small updates.

Chapter 14, Extending WiX, jumps into adding new, custom XML elements for extending the core functionality of WiX. We'll write a library, using C#, that takes our installer to places it's never been.

Chapter 15, Bootstrapping Prerequisites with Burn, discusses the new bootstrapping functionality called Burn. We'll create a single executable that installs all necessary prerequisites for our software.

Chapter 16, Customizing the Burn UI, solves the problem of customizing our Burn user interface by crafting a new one using C# and WPF. We'll discover the places where we can hook into the bootstrapper engine and how best to pass information from the user to our installation packages.

What you need for this book

In order to both write and run the code demonstrated in this book, you will need the following:

  • Visual Studio 2005 or newer (Standard Edition or higher)

  • The WiX toolset, which can be downloaded from http://wixtoolset.org/

Who this book is for

If you are a developer and want to create installers for software targeting the Windows platform, then this book is for you. Those new to WiX and Windows Installer should feel right at home as we start with the basics and gradually work up to more complex subjects. Others with more experience will benefit as we catalog the new features in WiX 3.6. If you're coming from an earlier version of WiX, you'll be happy to know that for the most part, things that used to work will still work. However, several tasks, such as implementing a major upgrade, have been simplified. We'll highlight the big changes, but keep an eye on familiar elements as some subtle changes have been made.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "If you would like conditions to be re-evaluated during a re-install, you should set the Transitive attribute on the parent component to yes."

A block of code is set as follows:

<Feature Id="MainFeature"
         Title="Main Feature"
         Level="1">
  <ComponentRef Id="CMP_InstallMeTXT" />

  <Condition Level="0">
    < ![CDATA[NOT REMOVE = "ALL" AND MyProperty = "some value"]]>
  </Condition>
</Feature>

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

<Property Id="MyProperty"
          Value="1" />
<Component Id="CMP_InstallMeTXT" 
           Guid="7AB5216B-2DB5-4A8A-9293-F6711FFAAA83">
  <File Id="FILE_InstallMeTXT" 
        Source="InstallMe.txt" 
        KeyPath="yes" />
  <Condition>MyProperty = 1</Condition>
</Component>

Any command-line input or output is written as follows:

msiexec /i myInstaller.msi /l*v install.log

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "using the Add Reference option in Solution Explorer".

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title through the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website, or added to any list of existing errata, under the Errata section of that title.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.