在dev,staging和生产环境之间区分web.config [英] Differentiating web.config between dev, staging and production environments

查看:4398
本文介绍了在dev,staging和生产环境之间区分web.config的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都有任何好的提示处理环境之间的web.config设置的差异?我考虑在源代码控制系统中创建一个config文件夹,但在Web层次结构之外,并让部署过程复制相应的配置文件(web.dev.config,web.staging.config,web.production.config )部署到web文件夹中。我也已经看到了如何在应用程序启动时以编程方式更改配置设置(WCF端点,连接字符串等)。

Anyone have any good tips on handling differences in web.config settings between environments? I've considered creating a 'config' folder in our source control system but outside of the web hierarchy, and having the deployment process copy the appropriate config files (web.dev.config,web.staging.config, web.production.config) into the web folder upon deployment. I've also seen posts on how to programmatically change the config settings (WCF endpoints, connection strings, etc) when the app starts.

2010年9月更新

值得注意的是,Visual Studio 2010通过 web.config transforms 。当您使用构建配置管理器(Build | Configuration Manager ...)为您的项目创建不同的配置(例如,Debug,Dev,Staging和Release)时,VS会向解决方案添加web。*。config文件。默认web.config包含您将用于调试的基准设置。 web.release.config,web.staging.config等包含XSLT转换,每当您根据活动构建配置发布项目时,将应用此转换。

It's worth noting that Visual Studio 2010 adds this ability via web.config transforms. When you use the build configuration manager (Build|Configuration Manager...) to create different configurations for your project (say, Debug, Dev, Staging and Release), VS adds web.*.config files to the solution. The default web.config contains baseline settings that you'll use for debugging. web.release.config, web.staging.config, etc contain XSLT transforms that will be applied whenever you publish your project based on the active build configuration.

推荐答案

使用新的VS,您可以使用Web配置转换。

With the new VS you can use web config transformations.

在这里阅读更多: http://msdn.microsoft.com/en-us/library/dd465326.aspx

这篇关于在dev,staging和生产环境之间区分web.config的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆