Adding a new element to an XML file during installation

In this recipe, we'll learn how to add an element to an XML file. One place where this might be useful is to enable tracing in an ASP.NET web application. Tracing lets you see diagnostic information about a running web application. We'll start with a basic Web.config file that doesn't have any tracing configuration in it and add a trace element to set it up.

Getting ready

To prepare for this recipe, perform the following steps:

  1. Create a new setup project and name it XmlElementInstaller.
  2. So that we'll have something to modify, 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 /> <system.web> ...

Get WiX Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.