C# Subversion 和 Visual Studio 项目的最佳实践

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1732813/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 20:23:18  来源:igfitidea点击:

Best practices for Subversion and Visual Studio projects

c#visual-studio-2010svnsvnignore

提问by Alex Marshall

I've recently started working on various C# projects in Visual Studio as part of a plan for a large scale system that will be used to replace our current system that's built from a cobbling-together of various programs and scripts written in C and Perl. The projects I'm now working on have reached critical mass for being committed to subversion. I was wondering what should and should not be committed to the repository for Visual Studio projects. I know that it's going to generate various files that are just build-artifacts and don't really need to be committed, and I was wondering if anybody had any advice for properly using SVN with Visual Studio. At the moment, I'm using an SVN 1.6 server with Visual Studio 2010 beta. Any advice, opinions are welcome.

我最近开始在 Visual Studio 中处理各种 C# 项目,作为大型系统计划的一部分,该系统将用于替换我们当前的系统,该系统由各种用 C 和 Perl 编写的程序和脚本拼凑而成。我现在从事的项目已经达到了致力于颠覆的临界质量。我想知道什么应该和不应该提交到 Visual Studio 项目的存储库。我知道它会生成各种文件,这些文件只是构建工件,实际上并不需要提交,我想知道是否有人对在 Visual Studio 中正确使用 SVN 有任何建议。目前,我正在使用带有 Visual Studio 2010 测试版的 SVN 1.6 服务器。欢迎任何建议,意见。

采纳答案by Justin R.

According to MSDN:

根据 MSDN

You can add the following files to Visual Studio source control:

  • Solution files (*.sln).
  • Project files, for example, *.csproj, *.vbprojfiles.
  • Application configuration files, based on XML, used to control run-time behavior of a Visual Studio project.

Files that you cannot add to source control include the following:

  • Solution user option files (*.suo).
  • Project user option files, for example, *.csproj.user, *.vbproj.userfiles.
  • Web information files, for example, *.csproj.webinfo, *.vbproj.webinfo, that control the virtual root location of a Web project.
  • Build output files, for example, *.dlland *.exefiles.

您可以将以下文件添加到 Visual Studio 源代码管理:

  • 解决方案文件 ( *.sln)。
  • 项目文件,例如*.csproj*.vbproj文件。
  • 基于 XML 的应用程序配置文件用于控制 Visual Studio 项目的运行时行为。

您无法添加到源代码管理的文件包括:

  • 解决方案用户选项文件 ( *.suo)。
  • 项目用户选项文件,例如*.csproj.user*.vbproj.user文件。
  • 网络信息的文件,例如*.csproj.webinfo*.vbproj.webinfo中,控制Web项目的虚拟根位置。
  • 例如,构建输出文件*.dll*.exe文件。

回答by adrianbanks

Solution level:

解决方案:

  • add the .slnsolution file
  • ignore the .suosolution user options file
  • 添加.sln解决方案文件
  • 忽略.suo解决方案用户选项文件

Project level:

项目级别:

  • add the .csproj, .vbproj(and c++ proj?) files
  • ignore the .csproj.user, .vbproj.userfiles
  • ignore the bindirectory
  • ignore the objdirectory
  • ignore any files/directories that get generated during runtime (ie. logs)
  • 添加.csproj, .vbproj(和 c++ proj?)文件
  • 忽略.csproj.user,.vbproj.user文件
  • 忽略bin目录
  • 忽略obj目录
  • 忽略运行时生成的任何文件/目录(即日志)

If you use and VS addins, they may generate files that also need ignoring (ie. ReSharper generates .resharperand .resharper.userfiles).

如果您使用 和 VS 插件,它们可能会生成也需要忽略的文件(即 ReSharper 生成.resharper.resharper.user文件)。

The ignore items can either be ignored explicitly by filename (ie. MyProject.csproj), or by a wildcard pattern (ie. *.csproj.user).

可以通过文件名(即MyProject.csproj)或通配符模式(即*.csproj.user)显式忽略忽略项。



Once you have your ignores set up, checking out a clean copy of your source then building should then show no modifications (ie. no new unversioned files).

一旦你设置了忽略,检查你的源代码的干净副本,然后构建应该显示没有修改(即没有新的未版本化文件)。

回答by GraemeF

I would suggest using AnkhSVN- a Subversion source control plugin for Visual Studio 2008/2010.

我建议使用AnkhSVN- Visual Studio 2008/2010 的 Subversion 源代码控制插件。

You can use it to perform your initial add and commit of the solution, projects and sources to the repository and it won't add any of the build artefacts. It won't add anything that is generated by your build, only files that are referenced by your solution. If there are any other bits and pieces you need that aren't in your solution, you can add them afterwards.

您可以使用它来执行您对存储库的解决方案、项目和源的初始添加和提交,并且它不会添加任何构建工件。它不会添加任何由您的构建生成的内容,只会添加您的解决方案引用的文件。如果您的解决方案中没有您需要的任何其他零碎部分,您可以在之后添加它们。

回答by Andre Gallo

I would manually include all files that I think I shouldn't version control.

我会手动包含所有我认为不应该进行版本控制的文件。

My global ignore pattern is:

我的全局忽略模式是:

.dll .pdb .exe .cache .webinfo .snk bin obj debug _Resharper .user resharper

.dll .pdb .exe .cache .webinfo .snk bin obj debug _Resharper .user resharper

回答by Michael Burr

Put the following files in version control:

将以下文件放入版本控制:

  • .dsw (VS6 workspace)
  • .dsp (VS6 project)
  • .sln (VS Solution)
  • .*proj (VS Project files of various types)
  • of course your source files and other artifacts you create
  • .dsw(VS6 工作区)
  • .dsp(VS6 项目)
  • .sln(VS 解决方案)
  • .*proj(各种类型的VS项目文件)
  • 当然,您创建的源文件和其他工件

Do notput the following files into version control:

不要把下面的文件版本控制:

  • .ncb (something to do with browsing or intellsense)
  • .suo (user workspace settings like window placement, etc - I think)
  • .user (user project settings like breakpoints, etc - I think)
  • .ncb(与浏览或智能有关)
  • .suo(用户工作区设置,如窗口放置等 - 我认为)
  • .user(用户项目设置,如断点等 - 我认为)

Also, don't put in any object files, executables, auto-generated files (like headers that might be generated).

另外,不要放入任何目标文件、可执行文件、自动生成的文件(如可能生成的头文件)。

As for executables and other generated files - there might be an exception if you want to be able to archive releases. That might be a good idea, but you'll probably want to manage that a little differently and possibly in a different place than your source code. If you do this, also archive your .pdb files so you can debug the stuff later. you might want to use a Symbol Server to store you archived symbols (see Debugging Tools for Windowsfor the symbol server and its documentation).

至于可执行文件和其他生成的文件 - 如果您希望能够存档版本,则可能会有例外。这可能是个好主意,但您可能希望以稍微不同的方式管理它,并且可能在与源代码不同的地方。如果您这样做,还要存档您的 .pdb 文件,以便您以后可以调试这些内容。您可能希望使用符号服务器来存储您归档的符号(请参阅符号服务器及其文档的Windows 调试工具)。

Here's my list of VS-specific files that I exclude from SVN:

这是我从 SVN 中排除的特定于 VS 的文件列表:

Ankh.Load
*.projdata
*.pdb
*.positions
*proj.user
*proj.*.user
*.ncb
*.suo
*.plg
*.opt
*.ilk
*.pch
*.idb
*.clw
*.aps

回答by Manoj

In case you are using ignore list, SVN is case sensitive. So remember to ignore bin and Bin folders separately.

如果您使用忽略列表,SVN 区分大小写。所以记得分别忽略 bin 和 Bin 文件夹。

Also, I had a question.. why does it take lot of time some times to refresh the status icon? At times it gets very confusing.

另外,我有一个问题..为什么刷新状态图标需要很多时间?有时它会变得非常混乱。

回答by CAD bloke

See Mercurial .hgignore for Visual Studio 2008 projectsfor a Mercurial ignore list. I'm not familiar with the syntax of the SVN ignore list but this thread has a few good lists of what to ignore in Visual Studio.

有关Mercurial忽略列表,请参阅Visual Studio 2008 项目的 Mercurial .hgignore。我不熟悉 SVN 忽略列表的语法,但是这个线程有一些很好的列表,说明了在 Visual Studio 中要忽略的内容。