We use file templates such as MyApp.config.template and MyWeb.config.template, with NAnt properties for bits that are different from each other. Therefore, the template file may look something like this:
<MyAppConfig> <DbConnString>${DbConnString}</DbConnString> <WebServiceUri uri="${WebServiceUri}" /> </MyAppConfig>
During the build, we generate all the configs for different environments, simply iterating over each environment in an NAnt script, changing the value of the NAnt $ {DbConnString} and $ {WebServiceUri} properties for each environment (in fact, they are all set in the same file with sections for each environment ) and make a copy of NAnt with the ability to extend the properties included.
It took a little time to set up, but he paid us at least ten times in the time spent using different versions of the configuration files.
source share