I’m playing around with XML transformations today and needed a refresher. This is a pretty good explanation straight from the horse’s mouth.
https://msdn.microsoft.com/en-us/library/dd465326(v=vs.110).aspx
I’m deploying to an Azure website, in which case there are ways to keep connection strings and app settings unique to each slot of your website. https://azure.microsoft.com/en-us/blog/windows-azure-web-sites-how-application-strings-and-connection-strings-work/
However, the setting I need to tweak for production isn’t an “app setting”, but rather a servicemodel client endpoint, which apparently has to be done the hard way. 🙁
3 Comments
Note: When your transformation is working, you can see the output in VS after a build here: \obj\Release\TransformWebConfig\transformed
This post shows the syntax for adding a dependent configuration specific config file.
http://www.olegsych.com/2010/12/config-file-transformation/
I hated the MS Xml configuration transformation mechanism so much that I wrote a simplified replacement, including a very optimized MS build task. I’ve never written this up on my blog, but the code and a brief description is here:
https://github.com/ashleyrtate/CoditateCommons
I’ve used it across several production projects with great success. It will be obsolete once the new ASP.NET 5 / Core .NET configuration mechanism becomes mainstream.
If you are interested in using it I will package up a sample project and a more comprehensive writeup.