Search code examples
.netxmlwcfweb-configenterprise-library

How to merge .net custom config sections for different environments


Our .net build system uses Enterprise Library 4.1 to replace default web.config settings by calling MergeConfiguration.exe and supplying the original web.config and the delta files for each environment (such as Test and Production) so that the resulting installer packages all environments' specific web.config and installs the correct version based on environment.

This works well for sections known to Enterprise Library, such as the appSettings section. However, we also have some custom sections which I would like to differentiate between environments, such as the following.

For Test

<RoutingSection type="AbcSystem.RoutingSection, AbcSystem"> <Route Source="1" Destination="2" /> ... </RoutingSection>

For Production

<RoutingSection type="AbcSystem.RoutingSection, AbcSystem"> <Route Source="1" Destination="3" /> ... </RoutingSection>

Ideally the whole custom section is specified in delta files, and during build, replaces its default version from the original web.config.

Without implementing our own delta merge tool, I have not found a solution. Believing this is a common need for software development, I am seeking for a solution, ideally one that does not involve too many changes to the aforementioned process. It does not have to be Enterprise Library. Thanks in advance.


Solution

  • I eventually used SlowCheetah, producing a transformed config file for each environment. It is also TFS build friendly, not requiring changes to the build process. I've also moved our merges previously done using Enterprise Library 4.1 to SlowCheetah, together with the custom sections.