CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

David Hayden [MVP C#]

         .NET Tutorials, Patterns, and Practices

Environmental Overrides in Enterprise Library 3.0

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 ( Automated Environmental Overrides Merging via Batch File or NAnt Build File ).

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


Published Apr 22 2007, 11:40 PM by David Hayden
Filed under:

Comments

Jeremy D. Miller said:

David,

You can do this in StructureMap too.  I've used it before for exactly the case you're describing.

# April 23, 2007 5:57 AM

David Hayden said:

Seriously? Very cool. I will have to download and try it out because I think Environmental Overrides is an excellent feature. I am overdue on downloading StructureMap anyway.

# April 23, 2007 11:03 AM
Check out Devlicio.us!

This Blog

Syndication

News

CodeBetter.Com Home