Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
WiX Cookbook
WiX Cookbook

WiX Cookbook: Over 60 hands-on recipes packed with tips and tricks to boost your Windows installations

Arrow left icon
Profile Icon Nicholas Matthew Ramirez
Arrow right icon
€18.99 per month
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.5 (10 Ratings)
Paperback Jan 2015 260 pages 1st Edition
eBook
€8.99 €29.99
Paperback
€36.99
Subscription
Free Trial
Renews at €18.99p/m
Arrow left icon
Profile Icon Nicholas Matthew Ramirez
Arrow right icon
€18.99 per month
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.5 (10 Ratings)
Paperback Jan 2015 260 pages 1st Edition
eBook
€8.99 €29.99
Paperback
€36.99
Subscription
Free Trial
Renews at €18.99p/m
eBook
€8.99 €29.99
Paperback
€36.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

WiX Cookbook

Chapter 1. Organizing and Building WiX Projects

In this chapter, we will cover the following topics:

  • Installing WiX and creating a new project in Visual Studio 2013
  • Referencing the output of a .NET console application in a WiX project by using a preprocessor variable
  • Separating a portion of WiX markup into its own library
  • Compiling a WiX installer on a build machine using MSBuild
  • Building a WiX installer from the command line

Introduction

The trouble with any bit of code is handling the logistics of getting it from development to production. How do we work on it in our favorite IDE initially and then allow it to be built elsewhere? Perhaps on a build server that doesn't have access to the IDE?

WiX solves this problem for its own code by allowing it to be built using a variety of workflows. As part of the WiX toolset, we get the compiler and linker needed to create an MSI installer. If we're using Visual Studio then we also get project templates that use these tools on our behalf so that the entire build process is effortless. If we're trying to fit WiX into an automated deployment pipeline, we can either call the compiler and linker from the command line or use ready-made MSBuild tasks.

The recipes in this chapter are designed to get you comfortable when working with a WiX project in Visual Studio and also building it in various ways outside of the IDE. This way, you'll know how to get it from development to production with ease.

Installing WiX and creating a new project in Visual Studio 2013

It's possible to work with WiX outside of Visual Studio, but within it, you'll benefit from the project templates; IntelliSense and shortcuts to the compiler and linker settings are available on the project's properties. The only downside is that WiX doesn't work with Visual Studio Express. However, its installer will give you the compiler and linker so that you can still get work done even if you're using Notepad to write the markup. SharpDevelop, a free and open source IDE, also supports WiX projects.

Getting WiX up and running starts with downloading and running its installer. This is a one-stop shop to update Visual Studio, getting the compiler and linker as well as other utilities to work with MSI packages. WiX supports Visual Studio 2005 and later, including Visual Studio 2013, which we'll cover here. In this recipe, we will download and install WiX and create our first setup project.

Getting ready

To prepare for this recipe, install Visual Studio 2013 and close it before installing WiX.

How to do it…

Download and install the WiX toolset to get access to new project templates, IntelliSense, and project properties in Visual Studio. The following steps will guide you:

  1. Open a browser, navigate to http://www.wixtoolset.org, and follow the link to the downloads page:
    How to do it…
  2. Once downloaded, launch the WiX installer and click on Install:
    How to do it…
  3. After completing the installation, open Visual Studio and go to File | New | Project | Windows Installer XML.
  4. Select the Setup Project template from the list of available project types. The version of .NET that's displayed has no bearing on the project since it's comprised of XML mark-up and not .NET code. Give the project a name and click on OK:
    How to do it…
  5. The project will initially include a file named Product.wxs, which contains the skeleton markup you'll need to create an installer:
    <?xml version="1.0" encoding="UTF-8"?>
    <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
      <Product Id="*" 
          Name="My Software" 
          Language="1033" 
          Version="1.0.0.0" 
          Manufacturer="My Company" 
          UpgradeCode="889e2707-5235-4d97-b178-cf0cb55d8ab8">
        <Package InstallerVersion="200" 
          Compressed="yes" 
          InstallScope="perMachine" />
    
        <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
        <MediaTemplate />
    
        <Feature Id="ProductFeature" 
          Title="MyFirstWixProject" Level="1">
          <ComponentGroupRef Id="ProductComponents" />
        </Feature>
      </Product>
    
      <Fragment>
        <Directory Id="TARGETDIR" Name="SourceDir">
          <Directory Id="ProgramFilesFolder">
            <Directory Id="INSTALLFOLDER" 
              Name="My Software" />
          </Directory>
        </Directory>
      </Fragment>
    
      <Fragment>
        <ComponentGroup Id="ProductComponents" 
          Directory="INSTALLFOLDER">
          <!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
          <!-- <Component Id="ProductComponent"> -->
            <!-- TODO: Insert files, registry keys, and other resources here. -->
          <!-- </Component> -->
        </ComponentGroup>
      </Fragment>
    </Wix>

How it works…

The WiX team has always worked quickly to keep up with the latest versions of Visual Studio. For example, WiX 3.9 supports Visual Studio 2013. When we launched the installer, it checked which versions of Visual Studio were present and registered its project templates with all that were compatible.

Behind the scenes, WiX introduces a new project type that has a .wixproj file extension. This project file contains MSBuild markup, which points to the WiX compiler and linker. Other IDEs, such as SharpDevelop, can take advantage of these project files to build MSI packages too.

The Product.wxs file contains everything we need to get started with writing WiX markup. The best coding practices for how to structure a WiX file have been defaulted for you. For example, the Directory elements are separated into a Fragment element so that directories are decoupled from the files that will go into them. A ComponentGroup has been set up with a comment guiding you to add Component elements to it. Each version of WiX brings a better Product.wxs file with it.

There's more…

If you were curious about what effect changing the version of the .NET framework listed in the drop-down list at the top of the New Project window would have, the answer, at least for setup projects, is nothing at all. A WiX file contains XML and is compiled with a specialized WiX compiler, so the version of .NET that we select will ultimately be ignored. That's not to say that it doesn't make a difference for any of the other project types. For example, C# Custom Action Project will have a dependency on the version of .NET that's selected. Anyone who uses the installer that in turn uses that custom action will need to have that version of .NET installed.

Referencing the output of a .NET console application in a WiX project by using a preprocessor variable

After setting up our WiX project, the first thing we'll probably want to do is package up the files that we plan to install. Since we're working in Visual Studio, we'll likely want to include the output of other projects such as the .exe file that's created from a console application project. At first, we could try hardcoding the path to the file:

<Component Id="cmpMyConsoleAppEXE" 
  Guid="{882DB6AA-1363-4724-8C43-2950E7ABECD4}">
  <File Source="..\MyConsoleApp\bin\Debug\MyConsoleApp.exe" />
</Component>

Although this works, it's a bit brittle and will break if the path to the file changes. Instead, we can use a preprocessor variable to store the path and allow Visual Studio to keep it up-to-date through the power of project references. In this recipe, we'll reference a console application's output and use a preprocessor variable to include that output in our installer.

Getting ready

To prepare for this recipe, create a new WiX setup project and name it ConsoleAppInstaller.

How to do it…

Use a preprocessor variable to get the path to a project's output with the following steps:

  1. Add a new C# console application to the same solution as the ConsoleAppInstaller setup project by right-clicking on the solution in Solution Explorer, going to Add | New Project… | Visual C# | Console Application and naming it TestApplication. The name matters as we'll be referencing it later:
    How to do it…
  2. Within the setup project, add a reference to TestApplication by right-clicking on the References node in Solution Explorer, choosing Add Reference..., and finding TestApplication under the Projects tab. Click on Add and then on OK:
    How to do it…
  3. Within the setup project, open Product.wxs and replace the ComponentGroup markup inside the last fragment with the following code:
    <ComponentGroup Id="ProductComponents" 
      Directory="INSTALLFOLDER">
      <Component Id="cmpTestApplicationEXE" 
        Guid="{6E2A6370-4784-4CF3-B42B-AA2D29EA5B1B}">
        <File Source="$(var.TestApplication.TargetDir)TestApplication.exe" />
      </Component>
    </ComponentGroup>
  4. Build the project and TestApplication.exe will be included in the MSI file. Note that you must set the EmbedCab attribute on the MediaTemplate element to yes to include the CAB file that WiX creates, which is where our .exe file is stored, inside the MSI. Also, this example assumes that TestApplication.exe is the only file you'd like to include in the installer. Other files, such as DLLs, can be included in the same way though.

How it works…

When we referenced the C# console application within the WiX setup project, the preprocessor variable $(var.[ProjectName].TargetDir) was made available to us, where ProjectName in this case is TestApplication. TargetDir points to the output directory of the console application project where our compiled TestApplication.exe file can be found.

Other preprocessor variables are also made available. For example, $(var.[ProjectName].TargetFileName) gives you the name of the compiled application, which for us would be TestApplication.exe. A full list of these variables can be found at http://wixtoolset.org/documentation/manual/v3/votive/votive_project_references.html.

Another benefit of referencing the console application project in this way is that it ensures it is compiled before our setup project is. This way, our installer always includes the most up-to-date version of the application.

Note

The GUID used for the Guid attribute on the Component element in this example can be any GUID, not just the one listed. You can generate a new one in Visual Studio by navigating to Tools | Create GUID. Use Registry Format as the GUID's format. More information can be found at http://wixtoolset.org/documentation/manual/v3/howtos/general/generate_guids.html.

You can also set the Guid attribute to an asterisk (*) or omit it altogether and WiX will set the GUID for you. You should choose your own if you plan on authoring a patch file for the application in the future or if the contents of Component don't contain an element that can be marked as a KeyPath element.

Separating a portion of WIX markup into its own library

As a project grows in complexity and size, we may end up with different teams building different parts of the software in relative isolation. Each team may want to control how their module will be installed or, during development, install only the modules that their code depends upon into their dev environment. To handle these scenarios, we can split our installer into chunks of WiX code called setup libraries.

A setup library can be compiled independently and plugged into the main, monolithic setup project later. We can also include the library in a team-owned setup project that only contains the modules required by the team. In essence, we can mix and match libraries wherever we need them to create installers for different purposes.

You might also want to share some complex installer markup, such as a user interface, with other installers, and a library is the perfect way to do this. Although it's outside the scope of this book, setup libraries are also used when building custom WiX extensions. In this recipe, we'll see how to create a setup library and include it in our setup project.

Getting ready

To prepare for this recipe, create a setup project and call it SetupLibraryInstaller.

How to do it…

Add a setup library to the solution and reference it in a setup project. The following steps show how to do this:

  1. Add a new setup library to the same solution as the setup project by right-clicking on the solution in Solution Explorer and navigating to Add | New Project... | Windows Installer XML | Setup Library Project. For this example, name the project MySetupLibrary:
    How to do it…
  2. After it's created, right-click on the MySetupLibrary project in Solution Explorer and go to Add | New Item… | Text File. Name the text file SampleTextFile.txt and click on Add. Our library will install this single text file.
  3. Right-click on the MySetupLibrary project in Solution Explorer again and select Properties. Select the Tool Settings tab and add -bf, which stands for bind files, to the librarian textbox, as shown in the following screenshot:
    How to do it…
  4. Open Library.wxs and replace the existing markup with the following:
    <?xml version="1.0" encoding="UTF-8"?>
    <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
      <Fragment>
        <DirectoryRef Id="INSTALLFOLDER">
          <Directory Id="SampleComponentsDirectory" 
            Name="Sample Components" />
        </DirectoryRef>
        
        <ComponentGroup Id="SampleComponentGroup" 
          Directory="SampleComponentsDirectory">
          <Component Id="cmpSampleTextFileTXT" 
            Guid="{5382BC02-4484-4C9B-8734-A99D20632EA9}">
            <File Source="SampleTextFile.txt" />
          </Component>
        </ComponentGroup>
    
        <Feature Id="SampleFeature">
          <ComponentGroupRef Id="SampleComponentGroup" />
        </Feature>
      </Fragment>
    </Wix>
  5. In the SetupLibraryInstaller project, add a reference to the setup library by right-clicking on the References node in Solution Explorer and selecting Add Reference…. Click on the Projects tab, highlight MySetupLibrary, click on Add, and then on OK.
  6. Open Product.wxs and add a FeatureRef element with an ID of SampleFeature. This includes the feature we added to the Library.wxs file of SetupLibrary in our installer. FeatureRef can go after the existing Feature element as follows:
    <Feature Id="ProductFeature" 
             Title="ConsoleAppInstaller" 
             Level="1">
      <ComponentGroupRef Id="ProductComponents" />
    </Feature>
    <FeatureRef Id="SampleFeature"/>

How it works…

Our setup library contains WiX markup to install a single text file called SampleTextFile.txt. Ordinarily, when you build a library like this, the source files don't get stored within it. Instead, only the WiX markup is compiled without any of the source files it refers to. In that case, we would have had to copy SampleTextFile.txt to the setup project's directory too, so that it can be found at link-time when compiling the installer.

However, because we added the -bf flag, which stands for bind files, to the Librarian settings, the text file was serialized and stored within the library. The -bf flag will handle serializing and storing any type of file including executables, images, and other binary data. Setup libraries are compiled into files with a .wixlib extension.

The markup we added to the library created a component, directory, and feature for the text file. To integrate the new directory with the existing directory structure as defined by our setup project, we chose to reference INSTALLFOLDER with a DirectoryRef element. Just be sure that there's a corresponding Directory element in your setup project that has this name. At link time, the DirectoryRef element in the library is merged with the Directory element in the setup project by matching their IDs. Once we had this, we were able to add a new subdirectory within the INSTALLFOLDER directory called Sample Components. After installation, we can see that the new directory was created and it contains our text file:

How it works…

To be sure that our library gets compiled before our setup project, we referenced it within the setup project using the References node. Then, to create a link to the library, we included a FeatureRef element in Product.wxs, which had an ID matching the Feature defined in the library. This pulls the Feature with all of its components into the installer.

There's more…

The setup libraries might contain more than just components, features, and directories. For example, they might define markup for a user interface using a UI element, which could then be linked to our installer with a UIRef element. Basically, if you can find a corresponding *Ref element, such as DirectoryRef, UIRef, ComponentGroupRef, or FeatureRef, then you'll be able to separate that type of element into a library and use its *Ref element to link it to the setup project.

Even if you can't find a corresponding *Ref element, as long as you have a reference of some kind, such as Property and PropertyRef, the rest of the elements in the library will be carried along with it into the installer. So, at the very least, you could include a single Property in the library and use that as the link between the library elements and the installer.

Compiling a WiX installer on a build machine using MSBuild

The WiX Toolset places its compiler and linker in C:\Program Files (x86)\WiX Toolset v3.9\bin. This is fine when compiling on your own machine but becomes a concern when you'd like to share your project with others or have it compile on a build server. WiX will have to be installed on each computer that builds the project.

Alternatively, we can store the WiX tools in source control, and then whoever needs to build a setup project can get everything they need by cloning the repository. This will also help us keep a handle on which version of WiX we're compiling against on a project-by-project basis.

In this recipe, we'll store the WiX binaries in a fictitious source control directory on the C: drive. We'll then update the .wixproj file of a setup project to use the MSBuild tasks stored there. I will be using a server with the Windows Server 2012 R2 operating system installed on it. You should be able to follow along with other versions of Windows Server.

Getting ready

To prepare for this recipe, perform the following steps:

  1. Install the .NET Framework 3.5. It's needed by the WiX build tasks. In Windows Server 2012 R2, it can be installed as a feature within Server Manager:
    Getting ready
  2. Next, we'll need the MSBuild engine, which is part of Microsoft Build Tools. It can be downloaded from http://www.microsoft.com/en-us/download/details.aspx?id=40760.
  3. After installing MSBuild, add its installation directory to the computer's PATH environment variable. Get there by right-clicking on This PC in file explorer and then going to Properties | Advanced system settings | Environment Variables.... Scroll through the list of system variables until you find the one labeled Path. Highlight it, click on Edit..., and then add the path to the MSBuild directory into the Variable value field, preceded by a semicolon. Then, click on OK:
    Getting ready

How to do it…

Download the WiX binaries and update your setup project to use the included MSBuild tasks:

  1. Open a browser, navigate to http://www.wixtoolset.org, and follow the link to the downloads page. Download wix39-binaries.zip:
    How to do it…
  2. Make sure that the ZIP file is unblocked by right-clicking on it, choosing Properties, clicking on Unblock (if you don't see it, just continue to the next step), and then on OK.
  3. Extract the contents of the ZIP file to C:\SourceControl\WiX39. Perform this step on both the server and on your own development computer so that our WiX projects can be built in both places using the MSBuild tasks from this folder (note that in a real-world scenario, our source control system would be responsible for copying the binaries to each computer):
    How to do it…
  4. We will build a simple setup project to confirm that we've got everything on the server configured correctly. Create a setup project on your development machine and call it BuildMachineInstaller.
  5. Open the BuildMachineInstaller.wixproj file and add the WixToolPath, WixTargetsPath, and WixTasksPath properties as shown, making sure that the value of WixToolPath ends in a backslash:
    <PropertyGroup>
        <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
        <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
        <ProductVersion>3.9</ProductVersion>
        <ProjectGuid>f80ca9fc-8e42-406e-92f9-06e484e94d67</ProjectGuid>
        <SchemaVersion>2.0</SchemaVersion>
        <OutputName>BuildMachineInstaller</OutputName>
        <OutputType>Package</OutputType>
        <WixToolPath>C:\SourceControl\WiX39\</WixToolPath>
        <WixTargetsPath>$(WixToolPath)wix.targets</WixTargetsPath>
        <WixTasksPath>$(WixToolPath)WixTasks.dll</WixTasksPath>
        <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
        <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
    </PropertyGroup>
  6. Copy the BuildMachineInstaller solution folder and all of its subfolders to C:\SourceControl on the build server.
  7. Open a command prompt via Run | cmd, execute the following commands to change the directory to the BuildMachineInstaller folder and compile the solution using MSBuild:
    cd C:\SourceControl\BuildMachineInstaller
    
    msbuild BuildMachineInstaller.sln 
    

How it works…

We started with a blank slate of a freshly installed Windows Server 2012 R2 operating system. Therefore, we had to install all the required software including .NET Framework 3.5 and Microsoft Build Tools 2013. The latter gives us the MSBuild engine, whose path we included in the computer's PATH environment variable.

Next, we downloaded the WiX binaries and copied them to C:\SourceControl. With a source control system, these files could be shared among all computers that need to compile our setup projects. We also had to update our project's .wixproj file so that it knew where to find these WiX binaries. This is accomplished by adding three MSBuild properties: WixToolPath, WixTargetsPath, and WixTasksPath. The first property sets the path to the WiX binaries, the second to the wix.targets file, and the third to WixTasks.dll. With all of this setup out of the way, we opened a command prompt, navigated to the folder where our solution file was on the build server, and compiled it using MSBuild.

Building a WiX installer from the command line

WiX has excellent integration with Visual Studio, but that shouldn't stop you from using it in other IDEs. We ought to be able to create an installer using only Notepad and the WiX compiler and linker if we wanted to. Luckily, WiX gives us the freedom to do this. In this recipe, we'll write a simple .wxs file and compile it into an MSI package using Candle, which is the WiX compiler, and Light, which is the WiX linker.

Getting ready

To prepare for this recipe, perform the following steps:

  1. Using a text editor such as Notepad, create a file called Product.wxs and add the following markup to it:
    <?xml version="1.0" encoding="UTF-8"?>
    <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
      <Product Id="*" 
               Name="My Software"
               Language="1033"
               Manufacturer="My Company"
               Version="1.0.0.0" 
               UpgradeCode="8c7d85db-b0d1-4a9a-85ea-130836aeef67">
        
        <Package InstallerVersion="200" 
                   Compressed="yes" 
                   InstallScope="perMachine" />
    
        <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
        <MediaTemplate EmbedCab="yes" />
    
        <Feature Id="ProductFeature" 
                   Title="The main feature" 
                   Level="1">
          <ComponentGroupRef Id="ProductComponents" />
        </Feature>
      </Product>
    
      <Fragment>
        <Directory Id="TARGETDIR" Name="SourceDir">
          <Directory Id="ProgramFilesFolder">
            <Directory Id="INSTALLFOLDER" 
                           Name="My Software" />
          </Directory>
        </Directory>
      </Fragment>
    
      <Fragment>
        <ComponentGroup Id="ProductComponents" 
                          Directory="INSTALLFOLDER">
          <Component Id="cmpMyTextFileTXT" 
                        Guid="{A4540658-09B6-46DA-8880-0B1962E06642}">
            <File Source="MyTextFile.txt" />
          </Component>
        </ComponentGroup>
      </Fragment>
    </Wix>
  2. This installs a text file called MyTextFile.txt. So, add a text file with this name to the same directory as Product.wxs. We will compile the two files from the command line to create an installer.

How to do it…

Open a command prompt and use candle.exe and light.exe to compile and link our WiX source file:

  1. Open a command prompt by navigating to Run | cmd.
  2. Change the directory to where the Product.wxs and MyTextFile.txt files are using the following command line:
    cd C:\MyProject
    
  3. Use Candle to compile the .wxs file into a .wixobj file and then place it in an output folder called obj. Be sure to surround the path to Candle, %WIX%bin\candle, with quotes since it will contain spaces when it is expanded:
    "%WIX%bin\candle" *.wxs -o obj\
    
  4. Use Light to link the text file and the .wixobj file together to form an MSI:
    "%WIX%bin\light" obj\*.wixobj -o bin\CommandLineInstaller.msi
    

How it works…

When we installed the WiX toolset, it gave us the WiX compiler, which is candle.exe, and linker, which is light.exe. These are the only tools we need to create an MSI from our WiX source file, Product.wxs. From the command line, we navigated to the directory where our source file was and then used Candle and Light to compile and link the file to create an MSI installer.

The first argument we passed to Candle was *.wxs. This selects all the .wxs files in the current directory and includes them in the compilation. Next, the -o argument tells Candle where to send the output of the compilation step. In this case, we sent it to a directory called obj. Note that the directory name ends in a backslash so that Candle knows that it's a directory. If it didn't exist before, it will be created.

The output of the Candle command was a file called Product.wixobj. This was an intermediate file that was picked up by light.exe in the next step. The first argument we passed to Light was the location of the .wixobj files: obj\*.wixobj. By using an asterisk, we select all the .wixobj files in the obj directory. The -o argument tells Light where to create the MSI file and what to name it. In this case, we create a file called CommandLineInstaller.msi.

How it works…

Another file called CommandLineInstaller.wixpdb was also created. This can be used when building patch files. You can learn more by reading Peter Marcu's blog post WiX: Introducing the WixPdb at http://petermarcu.blogspot.com/2008/02/wix-introducing-wixpdb.html.

There are a number of arguments that can be passed to Candle and Light that you might want to get to know. Passing the -? flag to either will give you a list of all the available options:

"%WIX%bin\candle" -?

"%WIX%bin\light" -?

Note

We used the %WIX% system environment variable to resolve the path to the WiX bin directory, where candle.exe and light.exe are present. This variable is added when you install the WiX toolset and resolves to C:\Program Files (x86)\WiX Toolset v3.9. It will not be present if you are using the WiX binaries directly without installing the WiX toolset.

Left arrow icon Right arrow icon

Description

WiX is a dialect of XML used to make installers for Windows. Its declarative style avoids the complexity and limitations of procedural code, providing you with everything you need to package up an entire application into a single MSI file. This book gives you a good overview of WiX's capabilities to develop your own installer packages with functionalities beyond those available in Windows Installer. In the recipes of this book, you will see ways in which WiX can cut down on your installation time and help you streamline your deployment processes. You will see how to make customized installer UIs, write custom actions, create shortcuts, and also set your application as the default for a file type.

Who is this book for?

If you are a developer with a good understanding of WiX projects and would like to further explore advanced WiX topics, this book is for you. To get the most out of this book, knowledge of proper XML syntax is recommended.

What you will learn

  • Install websites, application pools, and virtual directories in IIS
  • Add a wizard to your installer and customize it with your own dialogs
  • Set up new user accounts, add security groups, and secure files and folders on installation
  • Prevent deployment to unsupported systems by using launch conditions
  • Update XML files during installation
  • Configure shortcuts to your application
  • Include prerequisites with a bootstrapper
  • Create custom actions using C#
  • Add environment variables to the system

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jan 30, 2015
Length: 260 pages
Edition : 1st
Language : English
ISBN-13 : 9781784393212
Vendor :
Microsoft
Languages :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Jan 30, 2015
Length: 260 pages
Edition : 1st
Language : English
ISBN-13 : 9781784393212
Vendor :
Microsoft
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 120.97
WiX: A Developer's Guide to Windows Installer XML
€41.99
WiX 3.6: A Developer's Guide to Windows Installer XML
€41.99
WiX Cookbook
€36.99
Total 120.97 Stars icon
Banner background image

Table of Contents

14 Chapters
1. Organizing and Building WiX Projects Chevron down icon Chevron up icon
2. Installing Files and Directories Chevron down icon Chevron up icon
3. File and Folder Permissions Chevron down icon Chevron up icon
4. Shortcuts Chevron down icon Chevron up icon
5. Editing XML Files during Installation Chevron down icon Chevron up icon
6. Custom Actions Chevron down icon Chevron up icon
7. Installing Wizards Chevron down icon Chevron up icon
8. Users and Groups Chevron down icon Chevron up icon
9. Handling Prerequisites Chevron down icon Chevron up icon
10. Installing Websites Chevron down icon Chevron up icon
11. Linking to the Web Chevron down icon Chevron up icon
12. Installing SQL Server Databases Chevron down icon Chevron up icon
13. Admin Tasks Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.5
(10 Ratings)
5 star 50%
4 star 10%
3 star 10%
2 star 0%
1 star 30%
Filter icon Filter
Top Reviews

Filter reviews by




Jeffrey L. Odell Jun 07, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
An excellent follow-up to Nick's other book "A Developer's Guide to Windows Installer XML". I would suggest that first or as a pair. The former will help you understand how WIX is organized and best practices to integrating it in your projects. Once you have a sense of using WIX in your projects, Nick will save you a ton of time figuring out the approach to a bunch of common installer requirements with these recipes.For me, the initial purchase was around handling registry keys. Just sorting that out was worth the very reasonable price of the book.This is not necessarily a book you will read cover to cover but will dive in when a specific need arises. Should even one of the 50 recipes apply to your project it is worth the very reasonable price. I've gone back to it on several occasions.Nice job and the perfect WIX book set.
Amazon Verified review Amazon
Hallfire Jun 10, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
It's a gem. The author made navigating through wix and all it's tools a pleasure. Within the cookbook I found recipes for adding short cuts, dealing with permissions, Users and Groups, I was able to author a C# custom action and know where to hook it into the Windows Installer. Wix is amazing and this book makes learning how to use it easy. I highly recommend this book.
Amazon Verified review Amazon
Shivesh K Suman May 14, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I bought this Cookbook to get a quick start on WiX which I needed for a small project. I must say that this book really did enable me to accomplish what I wanted (in just one day). The bite size examples help you get started quickly. You may have to read from other sources in order to get a better bigger picture but this book is very helpful in getting quickly started with WiX and enabling you in creating installation kits. There are other parts of the book which are useful and I will continue to read it and refer to it.I wish there was a least one chapter which also provided a big picture overview of the installation process and various steps/install sequences - however this book is still a great quick start resource on using WiX in Visual Studio.---After few days of reading this book I would like to add that this book makes WiX appear simple and easy for you (and part of it is due to its simple and highly structured presentation). I highly recommend it!
Amazon Verified review Amazon
Amazonのお客様 Nov 12, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
WiX 3.6: A Developer's Guide to Windows Installer XML にもレビュー書きました。こちらはレシピ集なので、目次に必要なパターンがあれば、すぐにそれを使うことができます。所望のレシピがあれば、Google先生に聞くより数十倍は早く作業できます。2種類のインストーラをまとめたり、IISセットアップしたり、SQLサーバーもセットアップして、Web上の追加モジュールもインストールして、など、まずフツーの範囲ならこれが参考になるはずです。WiXはインストール対象のファイル一つ一つに対してXMLでゴリゴリ記述が必要ですが、そのあたりの簡易対応策は、Google先生から数パターンの回答が、キーワード次第でわりとすぐに見つかります。(そのサイトを理解するためにも、この書籍か、同じ著者のWiX 3.6: A Developer's Guide to Windows Installer XML は必要です。)
Amazon Verified review Amazon
Pavithra Jun 06, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This is a great book for intermediate as well as for enthusiastic beginner ;) . It covers nice and important code snippets, which makes our task quicker. I personally recommend this book to be read after previous releases.I would like to see,1. Using heat efficiently and with xslt to transform heat output.2. Installing both native and .net COM+(failures with enterpriseservices).3. Creating shortcuts on windows tiles.4. Debugging wix projs~Sampat
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.