VCS 中的 web.config 文件是否应该保持更新?
开发人员是否应该更新 web.config 文件并将其提交到 SVN 等 VCS?在我的公司,我们很少通过 SVN 更新它;相反,有人会在我们的部署脚本(SQL 脚本等,加上将 ASPX 文件编译为单独的 DLL 进行部署的批处理文件)中创建一个“指令”文本文件,其中包含类似“将 web.config 文件中的 X 更改为 Y”的内容站点 A、B 和 D”,并依赖于各个开发人员在每次更新文件时遵循这些说明。
这对我来说似乎违反直觉:我希望 web.config 文件根据需要保持同步,进行必要的更改并将文件作为代码库的任何其他工件提交,但我过去曾提出过这个问题但没有人在意它。
处理这样的配置文件时应该遵循什么方法?
Should developers keep the web.config file updated and commit it to a VCS such as SVN? At my company we very rarely update it via SVN; instead somebody will create an "instructions" text file in our deployment scripts (SQL scripts and the like, plus batch files to compile the ASPX files as individual DLLs for deployment) that says something like "Change X to Y in web.config files for Sites A, B and D", and relies on the individual developer following those instructions each time the file is updated.
This seems counter-intuitive to me: I would expect the web.config file to be kept in sync as needed, with necessary changes being made and the file committed as any other artifact of the codebase, but I have raised this issue in the past and nobody has paid it any mind.
What approach should be followed when dealing with config files like this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当然,Web 配置必须在源代码管理中,并且您可以使用 web.config 配置定义不同版本的 web.config 之间的差异,
例如我们有一个用于本地开发服务器,一个用于测试 IIS 服务器,一个用于生产 IIS 服务器。我们可以为不同的目标和不同的客户端(站点)设置解决方案配置并从 Visual Studio 发布。
以下是 web.config 配置的链接:
使用 Visual Studio 2010 进行常见的 Web.Config 转换
用于 Web 应用程序项目部署的 Web.config 转换语法
Absolutely, web config must be in source control, and you can define differences beetween various versions of web.config with web.config configurations
for example we have one for local development server, one for test IIS server, and one for production IIS server. And we can set solution configuration and publish from visual studio for different targets and different clients (sites).
here are the links for web.config configurations :
Common Web.Config transformations with Visual Studio 2010
Web.config Transformation Syntax for Web Application Project Deployment
我不会允许所有开发人员通过 SVN 或其他方式访问 web.config 文件。尽管如果在你们公司允许开发人员访问 web.config,我认为没有理由不将其放在 SVN 上。 SVN 的重点是跟踪您的单人/多人开发过程。如果您对 web.config 进行更改,并且这会导致其他人的代码出现错误,那么使用 SVN 恢复更改会更容易
I wouldn't allow all developers to have access to web.config file at all either via SVN or other way. Although if in your company it is allowed for developers to access web.config i see no reason why it shouldn't be on SVN. Point of SVN is to keep track of your single/multi person development process. If you make changes to web.config and this cause a bug in someone's else code it would be much easier to revert changes using SVN