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:
- Create a new setup project and name it
XmlElementInstaller
. - 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> <authentication mode="Windows" /> </system.web> </configuration>
- Add a Component element to
Product.wxs
to include the file in the installation...