你如何处理多个web.config文件是否有多个环境? [英] How do you handle multiple web.config files for multiple environments?
问题描述
我现在处理这个问题的方法是有多个配置文件,如:
The way I currently handle this is by having multiple config files such as:
web.config
web.Prod.config
web.QA.config
web.Dev.config
在该项目被部署到不同的环境,我只是用正确的设置重新命名相应的文件。
When the project gets deployed to the different environments I just rename the corresponding file with the correct settings.
人对如何处理这更好的建议?
Anyone have suggestions on how to handle this better?
编辑:
下面是一些在每个配置改变的事情:
Here are some of the things that change in each config:
- WCF客户端点URL和安全
- 自定义数据库CONFIGS
- 会话连接字符串
- log4net的设置
推荐答案
斯科特谷有一个<一个href=\"http://weblogs.asp.net/scottgu/archive/2007/09/21/tip-trick-automating-dev-qa-staging-and-production-web-config-settings-with-vs-2005.aspx\">article在这一次。该解决方案,他presented是使用pre-生成事件取决于所选择的构建配置正确的配置复制到的地方。
Scott Gu had an article on this once. The solution he presented was to use a Pre-build event to copy the correct config into place depending on the build configuration chosen.
我还注意到,已经有类似的<一个href=\"http://stackoverflow.com/questions/305447/using-different-web-config-in-development-and-production-environment\">question这里左右。
I also noticed that there already is a similar question here on SO.
这篇关于你如何处理多个web.config文件是否有多个环境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!