git 为什么会有 .sln、.suo 和 .csproj 文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3873839/
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
Why are there .sln, .suo and .csproj files?
提问by prosseek
I began to use Visual Studio 2010. After I'm done with the C# program, I see that there are .sln
, and .suo
files in the project root directory, and a .csproj
file in the subdirectory. What are those files for?
我开始使用Visual Studio 2010中,我与C#程序完成后,我看到有.sln
和.suo
文件在项目的根目录下,并且.csproj
在子目录中的文件。那些文件是干什么用的?
I need to identify the files to put into a Git repository. Together with the source code/documents that I create, I guess those three files are the only one that I have to take care of. However, I'm not sure if I'm tracking the correct files.
我需要确定要放入 Git 存储库的文件。连同我创建的源代码/文档,我想这三个文件是我唯一需要处理的文件。但是,我不确定我是否正在跟踪正确的文件。
ADDED
添加
How about the personal macro files? I have the Emacs key switch macro, does the .sln
file or .csproj
file have this macro?
个人宏文件呢?我有Emacs 按键开关宏,.sln
文件或.csproj
文件有这个宏吗?
回答by SLaks
You should commit the .sln
and the .csproj
, but not the .suo
or the .user
files.
您应该提交.sln
和.csproj
,而不是提交.suo
或.user
文件。
You can add the following to .gitignore
:
您可以将以下内容添加到.gitignore
:
#ignore thumbnails created by windows
Thumbs.db
#Ignore files build by Visual Studio
*.obj
*.exe
*.pdb
*.user
*.aps
*.pch
*.vspscc
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.cache
*.ilk
*.log
[Bb]in
[Dd]ebug*/
*.lib
*.sbr
obj/
[Rr]elease*/
_ReSharper*/
[Tt]est[Rr]esult*
回答by Nix
SLN (Solution) are the solution files. It stores info about the collection of projects that make up whatever you are developing. They contain projects, source control settings, or any other global level thing.
SLN(解决方案)是解决方案文件。它存储有关构成您正在开发的任何项目的项目集合的信息。它们包含项目、源代码控制设置或任何其他全局级别的东西。
CSProj(Project file) are the actual code projects (C# Libraries, WCF Services, etc). It stores information at the project level. It wraps all relevant References, Classess, etc..
CSProj(项目文件)是实际的代码项目(C# 库、WCF 服务等)。它在项目级别存储信息。它包装了所有相关的引用、类等。
SUO (solution user options) are user settings files. Completely disposable, you can delete it and the most common thing you will lose are breakpoints.
SUO(解决方案用户选项)是用户设置文件。完全一次性,你可以删除它,你会丢失的最常见的东西是断点。
Push everything except the SUO settings files.
推送除 SUO 设置文件之外的所有内容。
Do not include any bin, debug, obj directory. The only DLLs (or compiled/generated object) you should include are those that are external to your application.
不包含任何 bin、debug、obj 目录。您应该包含的唯一 DLL(或编译/生成的对象)是应用程序外部的那些。
回答by Nix
From MSDN:
来自 MSDN:
A solution (.sln)is a structure for organizing projects in Visual Studio. It performs a function similar to Windows Program Group (.vbg) files in Visual Basic 6.0 and project workspace (.dsw) files in Visual C++ 6.0. The solution maintains the state information for projects in .sln (text-based, shared) and .suo (binary, user-specific solution options) files … [Source]
一个解决方案(.sln)是在Visual Studio项目组织的结构。它执行类似于 Visual Basic 6.0 中的 Windows 程序组 (.vbg) 文件和 Visual C++ 6.0 中的项目工作区 (.dsw) 文件的功能。该解决方案在 .sln(基于文本的、共享的)和 .suo(二进制、用户特定的解决方案选项)文件中维护项目的状态信息...... [来源]
Furthermore, also from MSDN:
此外,也来自 MSDN:
The solution user options (.suo) fileis a structured storage, or compound, file stored in a binary format. You save user information into streams with the name of the stream being the key that will be used to identify the information in the .suo file … [Source]
该溶液用户选项(名为.suo)文件是一个结构化存储,或化合物,文件存储在二进制格式。您将用户信息保存到流中,流的名称是将用于识别 .suo 文件中信息的键...... [来源]
You do not need to put .suo
file in VCS. That is a user-specific file.
您不需要将.suo
文件放入 VCS。那是用户特定的文件。
回答by GR Envoy
The SUO files do have a purpose and I disagree with the statement that they should always be ignored. I do not ignore them, and as a general practice I add them to our SVN repository. My projects are not always using the solution defaults for Startup Project or platform. I find it annoying that if I grab a new project it does not default to 64 bit and the proper platform. The SUO contains the settings to set these defaults properly.
SUO 文件确实有目的,我不同意它们应该始终被忽略的说法。我不会忽略它们,作为一般做法,我将它们添加到我们的 SVN 存储库中。我的项目并不总是使用启动项目或平台的解决方案默认值。我觉得很烦人,如果我抓住一个新项目,它不会默认为 64 位和正确的平台。SUO 包含正确设置这些默认值的设置。
The down side of this is that it's a binary file, so pretty much each time you open the solution and do anything the file will have changed. Typically the file is less than 100k, and unless you know you changed something, I don't commit the change.
不利的一面是它是一个二进制文件,所以几乎每次打开解决方案并执行任何操作时文件都会发生变化。通常该文件小于 100k,除非您知道自己更改了某些内容,否则我不会提交更改。