visual-studio Visual C# Studio 项目中的哪些文件不需要版本化?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1644653/
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
Which files in a Visual C# Studio project don't need to be versioned?
提问by Kai
I'm new to Visual C# Studio (actually using the Express edition, but another developer is using the full version), and we are using version control (svn).
我是 Visual C# Studio 的新手(实际上使用的是 Express 版,但另一个开发人员使用的是完整版),我们正在使用版本控制 (svn)。
It's acceptable to me to add the project files to the repository, since this repo is just for the two of us using Visual C# Studio. But it feels like there are some irrelevant files in there. Can someone familiar with Visual C# Studio project files tell me which files can safely be svn:ignored?
我可以将项目文件添加到存储库中,因为这个存储库仅供我们两个使用 Visual C# Studio 的人使用。但是感觉里面有一些不相关的文件。熟悉 Visual C# Studio 项目文件的人可以告诉我哪些文件可以安全地被 svn:ignored 忽略吗?
Some suspect files:
一些可疑文件:
- project.csproj
- project.csproj.Debug.cachefile
- project.csproj.user
- project.sln
- project.suo
- Content\Content.contentproj
- 项目.csproj
- project.csproj.Debug.cachefile
- 项目.csproj.user
- 项目.sln
- 项目.suo
- 内容\Content.contentproj
I'm sure the .sln is required, but what's this .suo? and the .csproj? Can/should any of these be generated by Visual C# Studio on loading a project?
我确定 .sln 是必需的,但这是什么 .suo?和.csproj?在加载项目时,Visual C# Studio 可以/应该生成这些中的任何一个吗?
采纳答案by Carl Bergquist
Dont include
bin
obj
*.suo
*.user_Resharper*(if you have Resharper)
不要包含
bin
obj
*.suo
*.user _Resharper*(如果你有Resharper)
Include
*.sln
*.csproj
包括
*.sln
*.csproj
You can also check the .gitignore file for visual studio projectson github.
您还可以在 github 上查看 Visual Studio 项目的.gitignore 文件。
回答by Agent_9191
.csproj defines the project structure. It is vital.
.csproj 定义了项目结构。这是至关重要的。
This is what I add to my global ignore list in Tortoise SVN:
这是我在 Tortoise SVN 中添加到我的全局忽略列表中的内容:
*.suo *.user bin obj *.pdb *.cache *_svn *.svn *.suo *.user *.build-res TestResults _ReSharper*
回答by Jon Skeet
Shouldn't be versioned:
不应该版本化:
- .csproj.user is the user's project file settings (e.g. startup project)
- .suo is the user's solution file settings
- .csproj.user 是用户的项目文件设置(例如启动项目)
- .suo 是用户的解决方案文件设置
Should be versioned:
应该版本化:
- .sln is the solution file itself (what projects it contains etc)
- .csproj is the project file
- .sln 是解决方案文件本身(它包含哪些项目等)
- .csproj 是项目文件
I'm not sure about "contentproj" but it sounds like it's a project file which should be under svn.
我不确定“contentproj”,但听起来它是一个应该在 svn 下的项目文件。
回答by twk
The .sln file defines your solution together with the .proj files (one for each project), so keep them in your svn!
.sln 文件与 .proj 文件(每个项目一个)一起定义了您的解决方案,因此请将它们保存在您的 svn 中!
You can skip the .suo file (personal settings - binary anyway) as well as the bin or obj folders. Also the .cache files can be left.
您可以跳过 .suo 文件(个人设置 - 无论如何都是二进制文件)以及 bin 或 obj 文件夹。也可以保留 .cache 文件。
回答by Jason Punyon
Needed...
需要...
*.sln - The solution file contains references to all the projects and dependencies between the projects.
*.csproj - The project files themselves. These tell what files are included in the project, references, and the build steps for the project.
*.sln - 解决方案文件包含对所有项目的引用以及项目之间的依赖关系。
*.csproj - 项目文件本身。这些说明项目中包含哪些文件、引用以及项目的构建步骤。
Not...
不是...
*.suo - This is a user settings file...
*.suo - 这是一个用户设置文件...
回答by leppie
Just to add, anything that gets regenerated at build time, should be excluded. For example, files generated from the prebuild event or in some cases a custom tool.
补充一点,任何在构建时重新生成的东西都应该被排除在外。例如,从预构建事件或在某些情况下自定义工具生成的文件。
回答by Opster Elasticsearch - Nathan
Check this out - type visualstudioamd you will have a .gitignore file generated for you, also you can concatenate multiple languages/ide' ignore files together if you have a solution which contains multiple languages.
看看这个 -输入visualstudioamd你会为你生成一个.gitignore文件,如果你有一个包含多种语言的解决方案,你也可以将多种语言/ide'忽略文件连接在一起。
回答by Pac0
As this as not been indicated in other answers yet :
正如其他答案中尚未指出的那样:
In the case you are using Visual Studio with Unity 3D, you can safely add both *.csproj and *.sln to the .gitignore file, on the contrary of the usual case.
如果您将 Visual Studio与 Unity 3D 结合使用,则可以安全地将 *.csproj 和 *.sln 添加到 .gitignore 文件中,这与通常情况相反。
Indeed, the project structure is managed by Unity itself, not by Visual Studio. The only consequences of keeping them in source control are conflicts, even more so if for some reasons different Visual Studio versions are being used among commiters.
实际上,项目结构是由 Unity 自己管理的,而不是由 Visual Studio 管理的。将它们保留在源代码控制中的唯一后果是冲突,如果由于某些原因在提交者之间使用不同的 Visual Studio 版本,则更是如此。
Example .gitignore for Unity 3D : https://github.com/github/gitignore/blob/master/Unity.gitignore
Unity 3D 示例 .gitignore:https: //github.com/github/gitignore/blob/master/Unity.gitignore
回答by Gabriel Magana
You definitely need csproj files... You might want to try AnkhSVN or VisualSVN, those VS addins add only the required files to SVN.
您肯定需要 csproj 文件...您可能想尝试 AnkhSVN 或 VisualSVN,这些 VS 插件仅将所需文件添加到 SVN。
Or you could remove files from your directory structure until it does not load anymore.
或者您可以从目录结构中删除文件,直到它不再加载。
I suggest experimenting this way because it is a great way to learn how a solution is structures by VS.
我建议以这种方式进行试验,因为这是了解 VS 如何构建解决方案的好方法。
回答by Albireo
I leave out the Visual Studio Solution User Options file (*.suo) and the binaries directories as they get recompiled everytime you build your solution (the binand objfolders).
我省略了 Visual Studio 解决方案用户选项文件 (*.suo) 和二进制文件目录,因为它们在每次构建解决方案时都会重新编译(bin和obj文件夹)。

