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

Preface

The race to get software developed and deployed is reaching a dizzying pace. As companies accelerate their target release dates, topics such as continuous deployment, process automation, and DevOps take center stage. The need for a reliable and reproducible method of installing software is clear.

In this regard, it's easy to see where a tool like WiX can shine. Its XML syntax makes it easy to read, edit, and store in source control. It creates a package that can either be installed by nontechnical consumers with the click of a mouse or by a remote system administrator who needs to work from the command line. Probably its greatest strength is that it takes tasks that used to be performed by human beings and makes them automated. Think about installing databases, creating websites, and editing configuration files. These are all jobs that WiX can do at the time of installation. More than that, it can react to its environment, installing one file or another depending on the operating system, pulling down missing resources from the Web, and preventing installation on unsupported machines.

In this book, we'll cover many of these sorts of topics. Each chapter centers on a common theme, but taken together, they'll provide a good general overview of WiX's capabilities. You'll quickly see ways in which WiX can cut down on the time you might spend to manually set up your software now. For those who have only limited experience with WiX, the first few chapters should give you the background you need to be up and running. Those seeking to streamline their deployment processes will find the chapters on Windows user and group creation, file permissions, websites, and databases interesting. It's an exciting but challenging time for installation, and I hope you'll find that the recipes presented here give you the running start you'll need.

What this book covers

Chapter 1, Organizing and Building WiX Projects, helps you to build your WiX projects right, whether that means from Visual Studio, the command line, or on a build server with automation. We'll also see how to reference the output of other projects that will be included in the installer and how to separate WiX markup into libraries.

Chapter 2, Installing Files and Directories, covers creating folders and files on the end user's computer. We'll also see how to get heat.exe to generate this sort of markup for us and how to make decisions during installation about which files to create.

Chapter 3, File and Folder Permissions, introduces recipes to set the permissions on installed files and folders. We'll also see how to create file shares and choose a default program to use when opening a custom file type.

Chapter 4, Shortcuts, digs into all things related to shortcuts. We'll see how to put an icon on a shortcut, point a shortcut to a folder, as well as place a shortcut in the most popular places: the Start menu and the desktop. We'll also touch on how to create an advertised shortcut that will give users the ability to install features on demand.

Chapter 5, Editing XML Files during Installation, will come in handy especially when altering XML-based configuration files for your software. We'll add XML elements, remove them, set attributes, and insert inner text as part of our installation.

Chapter 6, Custom Actions, focuses on making well-behaved custom actions to extend the WiX functionality. We'll see how to protect the privacy of data sent to custom actions and open console windows without showing them, and rollback failures.

Chapter 7, Installing Wizards, puts a face on our installer by plugging in one of the wizards that comes with the WiX toolset. We'll then see how to customize it with our own images, license, and dialogs.

Chapter 8, Users and Groups, discusses adding users and groups to the target computer. We'll also see how to marry the two by adding users to groups and grant users the log on as a service security setting.

Chapter 9, Handling Prerequisites, includes tactics to only install our software to systems that can support it. We'll examine ways to stop an installation if prerequisites aren't met, install .NET Framework if it's missing, and download resources from the web during installation.

Chapter 10, Installing Websites, explores adding sites to IIS. We'll cover application pools, websites, virtual directories, and web applications. We'll then top it off with a recipe to secure a website with SSL.

Chapter 11, Linking to the Web, connects our installer to online resources. We'll see how to open web pages, display hyperlinks, and install shortcuts to websites.

Chapter 12, Installing SQL Server Databases, is dedicated to recipes about deploying SQL Server databases. If SQL Server isn't already installed on the target computer, we can install it with a bootstrapper. We'll add tables, insert data, and register an ODBC data source.

Chapter 13, Admin Tasks, rounds up a collection of administrative chores, including installing scheduled tasks, adding event sources, registering performance counters, and adding exceptions to the Windows firewall.

What you need for this book

To practice the recipes in this book, you will need the following:

  • Visual Studio 2010 or newer (not the Express version)

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

Who this book is for

Developers who are already familiar with WiX will have the easiest time, but those with less experience will likely be able to follow along as well. If you are completely new to WiX and Windows Installer, then I recommend beginning with WiX 3.6: A Developer's Guide to Windows Installer XML, Nick Ramirez, Packt Publishing. It provides more context for the newcomer and walks the reader through the basics of setting up an installer. Here, we'll head off the beaten track and cover some topics relevant to more advanced scenarios.

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, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, and user input are shown as follows: "Behind the scenes, WiX introduces a new project type that has a .wixproj file extension."

A block of code is set as follows:

<ComponentGroup Id="SampleComponentGroup" 
                Directory="SampleComponentsDirectory">
  <Component Id="cmpSampleTextFileTXT" 
             Guid="{5382BC02-4484-4C9B-8734-A99D20632EA9}">
    <File Source="SampleTextFile.txt" />
  </Component>
</ComponentGroup>

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

<ComponentGroup Id="SampleComponentGroup" 
                Directory="SampleComponentsDirectory">
  <Component Id="cmpSampleTextFileTXT" 
             Guid="{5382BC02-4484-4C9B-8734-A99D20632EA9}">
    <File Source="SampleTextFile.txt" />
  </Component>
</ComponentGroup>

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

# msiexec /i InstallPackageA.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: "Select the Setup Project template from the list of available project types."

Note

Warnings or important notes appear in a box like this.

Note

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 via 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/submit-errata, 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 on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

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.