Does anyone know of any good tools/utilities for managing Web.Config
files between different build/deployment environments?
For example, I have a WCF pr
I have traditionally used the multiple web.configs as you mentioned. It can be a pain but it is mitigated by file compare tools such as BeyoneComapare2 or KDIff...
Annoyance:
I mentioned my little cmd line app to merge XML docs in my 1st update... Well to do that I just use XmlDocument, and eventually just .Save() it to an FileStream.
Unfortuantely, the nodes aren't really in any particular order, and apparently, .NET requires the <configSections> element be the 1st child of the document.
I thought all these fancy tools were supposed to make programming life easier?
You want the XmlMassUpdate task in MSBuildCommunityTasks (does what you're trying to do with your xml console app)
http://msbuildtasks.tigris.org/
use it like this
<XmlMassUpdate Condition=" '@(ConfigTemplateFile)'!='' And '@(ConfigSubstitutionsFile)'!=''"
ContentFile="@(ConfigTemplateFile)"
SubstitutionsFile="@(ConfigSubstitutionsFile)"
MergedFile="@(ConfigFile)"
ContentRoot="/configuration"
SubstitutionsRoot="/configuration/substitutions/$(Configuration)"/>
I use the method explained by Scott Hanselman (he explains it much better than I can reproduce this so follow the link :) ) It has worked fine for me...
We use tags in our config files, that are replaced at build time to reflect the intended deployment environment. I've been inspired by Lavablast blog
It's nice to have only one template config file to manage.
The drawback is that you can't easily have custom "sections".
My favourite two ways of dealing with this are:
A. Keep the settings on the target machine* - In Azure for example you can setup application settings and connection strings that will override the values in web.config. (* - or target machine definition if your infrastructure configuration is dynamic).
B. Make the build/deployment tool (TeamCity, Octopus Deploy, etc, VS Team Services) inject the environment specific values as part of the build and/or deployment. Modern tools support encryption of sensitive settings.