Environmental Overrides in Enterprise Library 3.0 is a really cool feature that I have been playing with since the beta of Enterprise Library 3.0, but I actually put it to good use during a NAnt build process of a production application for the first time tonight ( .
You might miss this in the Enterprise Library Documentation, but there is a section called, Specifying Environment-Specific Configuration Settings, that discusses a console application called MergeConfiguration.exe to help you automate the creation of your environment specific configuration files. The application is in the bin directory with all the Enterprise Library assemblies that by default are located at C:\Program Files\Microsoft Enterprise Library 3.0 - April 2007\Bin unless you specify a different directory during installation.
The use of MergeConfiguration.exe is very simple:
MergeConfiguration.exe configFile deltaFile [mergedFile]
-
configFile. This is the main configuration file (.config). It is merged with the delta file.
-
deltaFile. This is the environment delta file (.dconfig). It contains the information that is merged into the main configuration file.
-
mergedFile. Thisis the output file. This file results from merging configFile with deltaFile. If you do not specify the mergedFile, the file name stored in deltaFile is used.
This is all really slick when you incorporate it into the build process. You can, of course, do the merging manually within the Enterprise Library 3.0 Configuration Editor which I talk more about in the following post: Environmental Overrides in Enterprise Library 3.0 - Managing Development, Test, Staging, and Production Configurations Made Easy!
I have it running via FinalBuilder as well, but I show a sample NAnt build file here just doing the merging. Cool stuff when you need to better manage your environment specific configuration settings.
by David Hayden