Project Description
This program is to help to merge different config files(environmental difference) and common config file into a single web.config/app.config.


Quite often we have to change our web.config settings when deploy into Build, Test etc. Rather than manually doing it, what I have done is:
delete web.config

create different config files in our project.
local.web.config - contains the settings for local only
build.web.config - contains the settings for build only
test.web.config - contains the settings for test only
common.web.config - contains the common settings (environment agnostic)

reference ConfigMerger in the web project, which does the merge

put the following code into the post-build event for our web project
$(WebProjectOutputDir)\bin\ConfigMerger.exe $(WebProjectOutputDir)\ local web.config common
bascially it calls configmerger.exe and passes four arguments {location, the $(Configuration) value, the to-be-updated/created .config file and prefix for common config}, what it does it to merge local.web.config and common.web.config into web.config at runtime.

and we could do the same for our nant script which contain a variable setting for $(Configuration) which could be build or test, depends where the code will be deployed to, web.config will be generated accordingly.

Note: the code is written in the way which I could use to make our deployment smoothly and wasnt really pretty as long as it does the job.

Last edited Jun 9, 2011 at 9:19 AM by dennisleng, version 2