In today's post, I'm going to talk about config transforms in Sitecore to help promote continuous integration. To run a Sitecore website, a lot of config file configuration is required. In Sitecore 6 the ability to use 'include' files were introduced to help developers manage change in the section. This was a great step forward but also raised the question of how do you transform values outside of the section. Some of the solutions in this post rely on TDS to be installed. TDS is a licensed deployment product for site, more information about it can be found from, here.
There are two considers you have to think about when dealing with transforms and Sitecore. First, is an understanding about how Sitecore configs are split up. Using config transforms is a staple of any standard .NET project but in Sitecore things might not work as you first expect. Out of every CMS system I've encountered, Sitecore by far uses the most amount of config files. There are so many that I'm fairly confident no developer will (or would want to) understand exactly what each one does. Instead of having one mega config file Sitecore has split the config files into smaller chunks that you can find in the 'App_Config' folder. It's very standard in Sitecore to have 40+ config files. When the application loads, Sitecore combines all these config files together to create one giant config file. The key thing to note is that Sitecore does this. This hasn't been done via Visual Studio, a build script or anything else. This means the way transforms are done for Sitecore do not work the same as other .NET solutions.
The second consideration about config files surrounds upgrading. On a normal web project, it is very common to have all your config settings and changes in your web.config file and the use a few transforms to deal with a handful of different environment level settings.
When you upgrade Sitecore from 7.2 -> 7.5, or, 7.5 -> 8.0 for example, as part of the upgrade process you will need to make a number of config changes to the web.config. As the Sitecore web.config is pretty large and complex the easiest way to upgrade is to use the default Sitecore web.config for the version you want to upgrade to and then re-merge your custom changes back in. For this reason, when using Sitecore, it is recommended to keep your web.config as simple as possible and to add any customization as config includes in your 'App_Config' folder. This makes the upgrade merge as simple as possible.
<setting name="MailServer" value="127.0.0.1" xdt:Transform="SetAttributes" xdt:Locator="Match(name)" />
<add key="Setting" value="Value" xdt:Transform="SetAttributes" xdt:Locator="Match(key)" />
<add key="Setting" value="Value" xdt:Transform="Insert" />
Software Architect, Programmer and Technologist Jon Jones is founder and CEO of London-based tech firm Digital Prompt. He has been working in the field for nearly a decade, specializing in new technologies and technical solution research in the web business. A passionate blogger by heart , speaker & consultant from England.. always on the hunt for the next challenge