I have been maintaining 2 different Web.Config files for ages, one for developement and one for live or remote deployed sites.
This is to say the least a pain. When you deploy your website you then need to remember to either copy the old config and replace or you need to edit the live one with the correct connection strings and the like.
While looking for a solution to a security related problem on a deployment of an ASP.NET site I came across this site:
http://www.troyhunt.com/2010/11/you-deploying-it-wrong-teamcity.html
2 Web Config files...
The essence of this shows how you can have a core web.config then you can have a debug web.config and a depolyed web.config.To do this all you do is in your Visual Studio project simply right-click the web.config file and select "Add Config Transforms". If it is greyed out / disabled then check if two files exists under Web.Config
One called Web.Debug.Config and once called Web.Release.Config.
These two files let you add anything in the file that is specific to that deployment, when writing codce the Debug.config is used and when deploying the web.release.config is used.
COOL hey, wow that prevents a lot of work.
Just a few things to note:
- weg.config is essentially the local copy of web.config. When you deploy web.release.config is the master
- Look at the demo strings in the files, you do not move the app settings into the Web.xxx.config, rather you replace it using
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"
Comments