您如何处理多个环境的多个 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 和安全性
- 自定义数据库配置
- 会话连接字符串
- log4net 设置
推荐答案
Scott Gu 有一个 文章 关于这一次.他提出的解决方案是使用预构建事件根据选择的构建配置将正确的配置复制到位.
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.
我也注意到已经有一个类似的问题 在这里.
I also noticed that there already is a similar question here on SO.
这篇关于您如何处理多个环境的多个 web.config 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!