When I talk to people about the XDT (web.config) transforms that web projects support for package/publish one of the most common questions is “Does this work for non-web projects?” Unfortunately the answer is No, but myself and a friend of mine (Chuck England) have created a Visual Studio add in which enables just this. You can find it in the Visual Studio gallery under the name SlowCheetah – XML Transforms. Here is an overview of the features of the add in.
- Add tooling to desktop project to create XDT transforms
- Transform app.config for desktop projects based on build configuration
- Transform any XML file to the output folder base on build configuration
- Add tooling to enable previewing XDT transforms
- For web projects easily transform other XML files during package/publish
After you install the add in you will get the following menu item when you right click any XML file.
For each build configuration defined you will get a transform created as a child item.
These files are stub XDT transforms. You can place your transform content in those files and they will be executed when you debug/run your application. For example if your app.config contained the following.
And your app.debug.config contained
When you run your application the config file created will contain the following.
Transforming other files
You are not limited to transforming app.config, you can transform any XML file. When you create a transform for an arbitrary XML file when you run your application the transformed XML file will be dropped into the output (bin) folder of your application.
You can easily preview transform results as well. After you have created the transform file you can right click on it and select Preview Transform.
After you click it you should see the following.
I hope you guys find this useful. Let me know if you have any feedback on this!
Note: This add in was created by me and a friend of mine, these are not created nor supported by Microsoft.
Sayed Ibrahim Hashimi – @sayedihashimi