Deploy Applications Using XDT Configuration Transformations

There are many techniques to build and deploy projects. However, I am not going to discuss the pluses or minuses of any of them. This article is about using XDT configuration transformations and related tools to make deployment easier and cleaner.

Use sections

Using sections in web.config makes it less messy and more readable. It also lets us split transformations between files and localizes it to a single responsibility principle.

<hibernate-configuration configSource="Config\\hibernate-configuration.config" />
<connectionStrings configSource="Config\\connectionStrings.config" />

However, there is one problem. How are we going to change those connection strings on build/deploy by using XDT transformations?

Possible solutions

One solution is to add transformation rules straight into the Web.Release.Config file by transforming configSource path to the appropriate path in Config folder, which contains release config files. However, this isn’t a clean or nice solution because it outfits transformation technique.

Another solution is to have the same configurations for each configuration file in Config folder as the web.config has (Debug, Release, Staging and etc.)


However, Visual Studio doesn’t have integration tools for that. To enable all xml file transformations we will use the SlowCheetah extension, which can be installed straight from the extension manager.

SlowCheetah benefits:

  1. It allows you to have different appSettings for debug and release and etc. when building your app.

  2. It allows you to transform any XML file with a clean and simple syntax.

  3. It allows you to tweak WCF service configuration in a straightforward way.

  4. It allows you to preview your XML transform without building/publishing your app.

  5. It allows you to transform files in addition to web.config on publish for Web projects.


After the package is installed, simply click on your config file and add transformations.


Then by adding some transformation rules, for example:

You can preview the output result by clicking "Preview Transform."


The new window will show original and transformed values. The final step is to use OneClick build or MsBuild build script to make a package. Do not forget to set Configuration = Release or Debug or other to get a correctly transformed output (Different configuration like Debug, Release, Staging, Dev, etc. can be created under Configuration Manager in the visual studio menu).

It would be too good to be true if that was all, wouldn’t it? Correct!

After you have done all of this and have taken a look at your package, you will see that you have not two files in your Config folder but as many of them as you have configurations in your solution.


You really don’t need all of these. What you need is two nicely transformed files. This is a 2.3 version bug. To fix this you have to download hot fix from GitHub and reinstall the package. Then set all config files “Build Action” to “None” under properties. This is the magic – now you have exactly what you need.


This bug fix will be included in 2.4 and later versions of SlowCheetah.


This solution is not self-contained. If you are using SlowCheetah you will either have to have the extension installed on all the dev machines (and the build server) or copy the required files to the expected path:


Advancing from continuous delivery to continuous deployment

Advancing from continuous delivery to continuous deployment

Download white paper