Replacing Values in Config Files

There will be many times that you will need to update an applications configuration file at build time. For example, you may need to update a connection string or the logging level. In order to update the configuration, we can use a set of XML-related tasks that is available from the Microsoft SDC Tasks library. You can find these at http://www.codeplex.com/sdctasks. In this example, I am going to update the config for the sample WindowsApplication1 project. The contents of the app.config file for that project are shown next.

<?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="configuration" value="default"/> <add key="webUrl" value="http://www.sedodream.com" /> </appSettings> </configuration> ...

Get Inside the Microsoft® Build Engine: Using MSBuild and Team Foundation Build now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.