半可编辑文件(例如配置文件)和版本控制-最佳做法? [英] Semi-editable Files (eg config files) and version control - best practices?

查看:140
本文介绍了半可编辑文件(例如配置文件)和版本控制-最佳做法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我今天通过检入配置文件杀死了该版本。它知道服务器的位置(例如SQL Server等),并且我一直在与在我的盒子上运行的服务器进行对抗。通常,或者在其他情况下,我们会在中央服务器上运行。当然,每天的构建都找不到我的服务器,因此损坏了。然后再一次,编辑配置文件以在签入之前指向普通服务器,然后在签入之后再次编辑它是很容易的。

So, I killed the build today by checking in a config file. It knows where the server is (think SQL server or the like), and I've been working against the server which runs on my box. Normally, or rather, under other circumstances, we'd run against the central server. The daily build, of course, didn't find 'my' server, hence the breakage. Then again, editing the config file to point to the 'normal' server before the checkin, and editing it again after checkin is tendious.

我很想拥有VC仅忽略配置文件,因此不会意外检入它。另一方面,存储库应包含文件的干净可用版本。现在,我无法忽略它并同时将其签入吗?

I've been tempted to have VC just ignore the config file, so that it doesn't get checked in accidentally. On the other hand, the repository should contain a clean, usable version of the file. I can't possibly ignore it and have it checked in at the same time, now, could I?

所以,我正在寻找的是一种拥有一个文件errr,该文件可以检出但从不检入。至少在最常见的情况下-如果配置文件发生重大更改,则可以执行一些特殊的步骤将新版本导入存储库。

So, what I'm looking for would be a way to have a file which, errr, which checks out, but never checks in. At least in the most common case - should the config file change significantly, some special procedure to get the new version into the repository would be doable.

如果您以前遇到过此问题,我会对您找到的任何解决方案感兴趣。只要他们不破坏构建,即;)

If You folks have come across this problem before, I'd be interested about any solutions You have found. As long as they don't break the build, that is ;)

推荐答案

您可以做的就是拥有默认配置文件除非添加一些新配置,否则它将保持不变。然后,您将拥有另一个文件,该文件将覆盖默认文件的配置。

What you can do is have a default config file that stays unchanged, unless some new config is added. Then you have a different file that overrides the default file's configs.

config.Default.xml
config.User.xml

仅config.Default.xml受源代码控制。 config.User.xml仅包含与您不同的配置。因此,假设您正在本地SQL服务器上进行测试,则只需在其中放置连接字符串,它将覆盖config.Default连接字符串。

Only config.Default.xml is source controlled. config.User.xml contains only the configurations that are different for you. So, say you are testing on a local SQL server, you put only the connection string in there and it will override the config.Default connection string.

看看.Net Framwork应用程序配置,它将为您完成大部分(如果不是全部)工作。

Take a look at .Net Framwork Application Configuration, it does most (if not all) of the work for you.

这篇关于半可编辑文件(例如配置文件)和版本控制-最佳做法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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