什么是处理在ASP.Net的web.config文件版本的最好方法? [英] What's the best way to handle web.config file versions in ASP.Net?

查看:129
本文介绍了什么是处理在ASP.Net的web.config文件版本的最好方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.Net网站(ASPX和ASMX页)用一个单一的web.config文件。我们有一个开发版本和产品版本。随着时间的推移,开发和生产的web.config文件中已经实质性地发散。

I have an ASP.Net web site (ASPX and ASMX pages) with a single web.config file. We have a development version and a production version. Over time, the web.config files for development and production have diverged substantially.

什么是保持web.config中的两个版本的源代码管理的最佳实践(我们使用乌龟SVN,但我不认为事情)?好像我能像web.config.prod一个名为添加生产的web.config文件,然后当我们成交的所有文件,我们想补充删除现有的web.config和重命名web.config文件的步骤.prod到web.config中。

What is the best practice for keeping both versions of web.config in source control (we use Tortoise SVN but I don't think that matters)? It seems like I could add the production web.config file with a name like "web.config.prod", and then when we turnover all the files we would just add the step of deleting the existing web.config and renaming web.config.prod to web.config.

这似乎hackish的,但我敢肯定它会工作。不是有某种机制来处理这个内置到Visual Studio?看起来这将是一个常见的​​问题,但我还没有发现任何问题(附答案)这个问题。

This seems hackish, although I'm sure it would work. Is there not some mechanism for dealing with this built in to Visual Studio? It seems like this would be a common issue, but I haven't found any questions (with answers) about this.

推荐答案

我们使用你所描述的具体方法,它的伟大工程,比如我们有:

We use the exact method you describe, it works great, for example we have:


  • 的web.config (本地开发)

  • web.Dev.config (构建服务器,建立在办理入住手续)

  • web.QC.config (测试环境下)

  • web.Prod.config (生产)

  • web.config (for local development)
  • web.Dev.config (build server, builds on check-in)
  • web.QC.config (testing environment)
  • web.Prod.config (production)

为每个环境的构建脚本只是删除web.config中并重命名一个适当的在它的位置。这样的方式可以让你轻松控制源所有这些并很快做一个diff,看看有什么可能是环境之间的不同。全线更新配置值更容易,以及...它推到那个环境下时间,它会得到新的配置。

The build script for each environment just deletes the web.config and renames the appropriate one in it's place. Doing this way allows you to easily source control all of them and very quickly do a diff and see what may be different between environments. Updating a config value across the board is much easier as well...the next time it's pushed to that environment, it'll get the new config.

这篇关于什么是处理在ASP.Net的web.config文件版本的最好方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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