This package allows you to automatically transform your app.config (or any file) when you press F5 in Visual Studio. You can have different transformations based on the build configuration. This will enable you to easily have different app settings, connection strings, etc for Debug versus Release. If you want to transform other files you can do that too. Here are some other reasons why you might want to install this package.
Have you ever:
- Wanted to have different appSettings for debug and release when building your
- Wanted to use different connection strings based on your build configuration
when building your app?
- Wanted to transform any XML file with a clean and simple syntax?
- Wanted to tweak WCF service configuration in a straight foward way?
- Wanted to preview your XML transform without building/publishing your app?
- Wanted to transform files in addition to web.config on publish for Web projects?
If you answered Yes to any of these then you should download this package.
Getting started is really simple, just install this package. Then in the solution explorer you can easily add your config transform by right-clicking and selecting Add Transform.
After you add the transform you will notice a transform for each build configuration.
You can place your customizations inside of the transform files, for example if you want to tweak app settings and connection strings you might use the syntax shown below.
<?xml version="1.0" encoding="utf-8" ?>
<!-- For more information on using transformations see the web.comfig examples at http://go.microsoft.com/fwlink/?LinkId=214134\. -->
<appSettings> <add key="appName" value="WPF Demo-Release" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
<add key="url" value="http://contoso.com/" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
<add key="email" value="firstname.lastname@example.org" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
<add name="RecordsDb" connectionString="db.contoso.com;Initial Catalog=RecordsDb;Integrated Security=true" xdt:Transform="Replace" xdt:Locator="Match(name)"/>
<add name="InventoryDb" connectionString="db.constos.com;Initial Catalog=InventoryDb;Integrated Security=true" xdt:Transform="Insert" xdt:Locator="Match(name)" />
When you build your applicatoin the files are transformed and dropped into the output directory. If you are transforming the app.config then when the file is transformed it will be renamed in the output directory as usual to ensure that your application picks it up at runtime.