使用 SVN 管理开发和生产服务器之间的配置文件差异 [英] Manage config file differences between development and production servers with SVN

查看:38
本文介绍了使用 SVN 管理开发和生产服务器之间的配置文件差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些 .NET 应用程序的文件,它们在生产服务器和开发服务器中是不同的.例如:

I have a few files of a .NET app that are different in the production server from the development server. For example:

  • Web.config
  • MasterPage.master
  • account/account.aspx
  • 博客/Web.config
  • 还有一些……

使用 SVN 管理这些差异的最佳方法是什么?我听说过从在主干中维护配置文件夹到使用不同"文件创建分支,然后将它们合并到发布标签中.

What is the best way to manage these differences with SVN? I've heard everything from maintaining a config folder in the trunk to creating a branch with the "different" files, then merging them into the release tag.

我使用 SVN 主干进行主要开发(稳定),并在准备发布时标记主干.主干部署到我的开发服务器,发布标签通过 FTP 部署到生产服务器.

I use SVN trunk for main development (stable) and tag the trunk when it's ready to be released. The trunk deploys to my development server and the release tag deploys to the production server via FTP.

推荐答案

一种可能性是将其留给您的构建/部署过程.

One possibility is to leave this up to your build/deploy process.

因此,对于 Web.config,您将在 SVN 中拥有以下内容:Web.config(这可以是你的开发版本)web.config.qa(如果你有qa环境)Web.config.prod

So, for Web.config you would have the following in SVN: Web.config (this can be your development version) Web.config.qa (if you have a qa environment) Web.config.prod

在构建/部署时,您的部署过程知道"它正在部署到什么环境(基于您控制它的方式 - 环境变量、脚本参数等),并在其位置替换正确的配置文件.

At build/deploy time, your deployment process "knows" what environment it is deploying to (based on however you control this - environment variables, script parameters, etc), and substitutes the correct config file in its place.

我更喜欢这种方法,因为它使您的目录和文件结构保持完整(相对于有一个 config 文件夹),并且避免了不必要的分支和合并的麻烦.它确实需要努力确保在进行非特定于环境的更改时更新所有文件,但无论策略如何,您都将为此付出代价.

I prefer this method because it leaves your directory and file structure intact (vs. having a config folder), as well as avoiding unnecessary branches and merging pains. It does require diligence in ensuring that all the files are updated when changes are made that aren't environment specific, but you are going to pay this price regardless of strategy.

这篇关于使用 SVN 管理开发和生产服务器之间的配置文件差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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