简体   繁体   English

为什么会有 .sln、.suo 和 .csproj 文件?

[英]Why are there .sln, .suo and .csproj files?

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.我开始使用Visual Studio 2010。在我完成C#程序后,我看到项目根目录中有.sln.suo文件,子目录中有一个.csproj文件。 What are those files for?那些文件是干什么用的?

I need to identify the files to put into a Git repository.我需要确定要放入 Git 存储库的文件。 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.但是,我不确定我是否正在跟踪正确的文件。

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文件有这个宏吗?

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*

SLN (Solution) are the solution files. SLN(解决方案)是解决方案文件。 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. 它们包含项目,源代码控制设置或任何其他全局级别的东西。

CSProj(Project file) are the actual code projects (C# Libraries, WCF Services, etc). CSProj(项目文件)是实际的代码项目(C#Libraries,WCF Services等)。 It stores information at the project level. 它在项目级别存储信息。 It wraps all relevant References, Classess, etc.. 它包含了所有相关的参考文献,Classess等。

SUO (solution user options) are user settings files. SUO(解决方案用户选项)是用户设置文件。 Completely disposable, you can delete it and the most common thing you will lose are breakpoints. 完全一次性,你可以删除它,你将失去的最常见的事情是断点。


Push everything except the SUO settings files. 推送除SUO设置文件之外的所有内容。

Do not include any bin, debug, obj directory. 不要包含任何bin,debug,obj目录。 The only DLLs (or compiled/generated object) you should include are those that are external to your application. 您应该包含的唯一DLL(或编译/生成的对象)是应用程序外部的DLL。

From MSDN: 来自MSDN:

A solution (.sln) is a structure for organizing projects in Visual Studio. 解决方案(.sln)是用于在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. 它执行类似于Visual Basic 6.0中的Windows程序组(.vbg)文件和Visual C ++ 6.0中的项目工作区(.dsw)文件的功能。 The solution maintains the state information for projects in .sln (text-based, shared) and .suo (binary, user-specific solution options) files … [Source] 该解决方案维护.sln(基于文本,共享)和.suo(二进制,用户特定的解决方案选项)文件中项目的状态信息... [来源]

Furthermore, also from MSDN: 此外,还来自MSDN:

The solution user options (.suo) file is a structured storage, or compound, file stored in a binary format. 解决方案用户选项(.suo)文件是以二进制格式存储的结构化存储或复合文件。 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文件中信息的密钥... [来源]

You do not need to put .suo file in VCS. 您不需要将.suo文件放在VCS中。 That is a user-specific file. 这是一个特定于用户的文件。

The SUO files do have a purpose and I disagree with the statement that they should always be ignored. SUO文件确实有目的,我不同意应该始终忽略它们的说法。 I do not ignore them, and as a general practice I add them to our SVN repository. 我不会忽略它们,作为一般做法,我将它们添加到我们的SVN存储库中。 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. 我觉得很烦人,如果我抓住一个新项目,它不会默认为64位和适当的平台。 The SUO contains the settings to set these defaults properly. 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,除非你知道你改变了什么,否则我不提交更改。

就我而言,我删除了解决方案和项目中的所有“bin”和“obj”文件夹

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 编辑sln,proj,suo文件的最佳实践? - Best practices for editing sln, proj, suo files? Visual Studio 2008 - 移动解决方案文件(sln,suo) - Visual Studio 2008 - Moving solution files (sln, suo) 为什么“设置为启动”选项存储在 suo 文件而不是 sln 文件中? - Why is “Set as Startup” option stored in the suo file and not the sln file? Visual Studio,svn以及合并.csproj和.sln文件 - Visual Studio, svn and merging .csproj and .sln files 是否有用于以编程方式更改项目和解决方案文件的API(.vbproj,.csproj,.sln)? - Is there an API for programmatically altering Project and Solution files (.vbproj, .csproj, .sln)? 轻量级文本/代码编辑器,可以打开.SLN和.CSProj文件 - Light weight text/code editor that can open .SLN, and .CSProj Files 如何从ascmd.cs -.csproj和-.sln文件获取ascms.exe? - How to get ascms.exe from ascmd.cs -.csproj and -.sln files? 您可以将Visual Studio源代码控制绑定信息保留在.sln和.csproj文件之外吗? - Can you keep Visual Studio source control binding info out of .sln and .csproj files? 使用 MSBuild 构建多个 .csproj 文件时创建“内存中 .sln” - Creating an “in-memory .sln” when building multiple .csproj files using MSBuild 在VS中查找文本,包括.sln和.csproj文件 - Find text in VS including .sln and .csproj file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM