asp.net - 在 Subversion 中存储 ASP.NET 网站的最佳实践?

标签 asp.net svn

我目前正在与多个开发人员一起使用 Subversion 进行代码分发的 ASP.NET 项目,但坦率地说,目前完全搞砸了。设置 Subversion 存储库的人包含了特定于他们的计算机的配置文件、bin\* 目录和其他类似的东西。

作为必须检查这个存储库并让它在我的计算机上运行的人,我对此感到非常沮丧,因为我花了一段时间来整理它以使其完全编译。现在我正在考虑为 Subversion 指南编写一份文档发送给我公司的技术负责人,以便我们可以使流程标准化并避免此类问题。

我正在寻找的是对指南的输入。这是他们的开始,希望我们能从中有所收获:

The file structure should be set up to have third-party libraries checked in outside the build output directories (since they won't be included in the repository.) The name of this directory should be "Libraries".

No machine-specific files should be included in Subversion. Therefore, only a template of Web.config is checked in, which is customized by the developers to suit their machine. This behavior is included in Visual Studio 2010 by default and the individual configuration files (Web.Local.config) automatically have the template (Web.config) applied. The local configuration file still shouldn't be included in Subversion though, so long as it applies for a specific machine.

Solution and project files must not contain any absolute paths.

An ignore list should be set up. Start with:

'
*.user
obj
'

Example file structure for an ASP.NET 2.0 web site with a class library specific to the web site and a third-party library:

'
/trunk/
    Libraries/
        ThirdParty.dll
    MyClassLibrary/
        bin/  [Ignore]
        obj/  [Ignore]
        Properties/
            AssemblyInfo.cs
        SomeClass.cs
        MyClassLibrary.csproj
            - Holds references to third-party libraries. For example:
              ../Libraries/ThirdParty.dll
    MyWebApplication/
        bin/
            ThirdParty.dll  [Ignore; copied by build process]
            ThirdParty.dll.refresh
                - Contains "../Libraries/ThirdParty.dll"
        Default.aspx
        Default.aspx.cs
        Web.config  [Ignore]
        Web.config.template
    MySolution.sln
        - Holds list of projects.
        - Has reference information for projects.
'

An alternative to using Web.config.template would be to include a Local.config file from Web.config, but this might be less flexible.

When using a Web Application project rather than a Web Site project, the references will be stored in the project file instead of in .refresh files, so the bin/ folder will be ignored.



有人可以看到上述建议中的错误吗?是不是缺少了什么?有人对忽略列表有建议吗?我现在只是从几个条目开始。

最佳答案

我认为你是一个很好的方式。但是为什么不忽略/MyWebApplication 中的整个 bin 文件夹,而不是文件呢?您不会将构建输出添加到 subversion 中,对吗?我肯定会认为这是一种不好的做法。

此外,如果可能,您可以将 web.config 文件添加到 subversion,但在元素中引用一个带有 appSettings 的新文件:例如

<appSettings file="local.config">

然后让 svn 忽略 local.config 文件。我一直都是这样操作的。

但是当然这只有在每个可配置参数都在 appSettings 中时才有效(这是我不喜欢提供者模型的原因之一,因为所有提供者都需要从 connectionString 元素获取连接字符串,并且您无法重新配置它们以获取连接字符串来自 appSettings)

编辑 : troethom 启发了我并指出,您还可以在单​​独的文件中覆盖 connectionString 配置设置
<connectionStrings configSource="ConnectionStrings.config"/>.

所以我要做的就是将实际的 web.config 文件置于 subversion 控制之下,但让 svn 忽略那些覆盖本地设置的其他文件。

关于asp.net - 在 Subversion 中存储 ASP.NET 网站的最佳实践?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1357244/

相关文章:

asp.net - BlackBerry Web 服务调用参数编码

svn - Subversion 的隐藏修订文件

security - 使用在线 SVN 存储库有多安全?

SVN 差异导出

SVN导入排除文件

javascript - 为什么我的 $.ajax() JSON 数据会像这样发回服务器?

c# - 文件下载后要执行的代码在 Asp.net 中不起作用

asp.net - 加载数据库图像的最佳方法

asp.net - UserPrincipal.FindByIdentity 在 IIS 服务器上返回 null

php - 使用TortoiseSVN删除冲突文件(本地文件)后无法更新文件