Book Image

WiX Cookbook

By : Nicholas Matthew Ramirez
1 (1)
Book Image

WiX Cookbook

1 (1)
By: Nicholas Matthew Ramirez

Overview of this book

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.
Table of Contents (15 chapters)
14
Index

Setting the value of an attribute on an XML element


Although settings can often be configured by adding entire elements, others can be configured by setting an attribute on an already existing element. For example, we can replace a default database connection string by setting the connectionString attribute on an add element. By doing it at installation time, we're given the flexibility to collect the connection details from the user or base them on the environment in which the installer is running. In this recipe, we'll see how to use the XmlConfig element to change a default connection string to something else.

Getting ready

To prepare for this recipe, perform the following steps:

  1. Create a new setup project and name it XmlAttributeInstaller.

  2. Add an XML file to the project and call it Web.config. Add the following markup to it:

    <?xml version="1.0"?>
    <configuration>
      <appSettings />
      <connectionStrings>
        <add name="mydb" providerName="System.Data.SqlClient" connectionString...