简体   繁体   English

我应该将 Visual Studio .suo 和 .user 文件添加到源代码管理吗?

[英]Should I add the Visual Studio .suo and .user files to source control?

Visual Studio solutions contain two types of hidden user files. Visual Studio 解决方案包含两种类型的隐藏用户文件。 One is the solution .suo file which is a binary file.一种是解决方案.suo文件,它是一个二进制文件。 The other is the project .user file which is a text file.另一个是项目.user文件,它是一个文本文件。 Exactly what data do these files contain?这些文件究竟包含哪些数据?

I've also been wondering whether I should add these files to source control (Subversion in my case).我也一直想知道我是否应该将这些文件添加到源代码管理中(在我的例子中是 Subversion)。 If I don't add these files and another developer checks out the solution, will Visual Studio automatically create new user files?如果我不添加这些文件而另一个开发人员签出解决方案,Visual Studio 会自动创建新的用户文件吗?

These files contain user preference configurations that are in general specific to your machine, so it's better not to put it in SCM.这些文件包含通常特定于您的机器的用户首选项配置,因此最好不要将其放在 SCM 中。 Also, VS will change it almost every time you execute it, so it will always be marked by the SCM as 'changed'.此外,VS 几乎每次执行时都会更改它,因此 SCM 将始终将其标记为“已更改”。 I don't include either, I'm in a project using VS for 2 years and had no problems doing that.我也不包括,我在一个使用 VS 的项目中使用了 2 年,并且没有任何问题。 The only minor annoyance is that the debug parameters (execution path, deployment target, etc.) are stored in one of those files (don't know which), so if you have a standard for them you won't be able to 'publish' it via SCM for other developers to have the entire development environment 'ready to use'.唯一的小烦恼是调试参数(执行路径、部署目标等)存储在这些文件之一(不知道是哪个)中,所以如果你有一个标准,你将无法'通过 SCM 为其他开发人员发布'它,让整个开发环境'准备好使用'。

你不需要添加这些——它们包含每个用户的设置,其他开发人员不会想要你的副本。

Others have explained why having the *.suo and *.user files under source control is not a good idea.其他人解释了为什么将*.suo*.user文件置于源代码管理之下并不是一个好主意。

I'd like to suggest that you add these patterns to the svn:ignore property for 2 reasons:我建议您将这些模式添加到svn:ignore属性中,原因有两个:

  1. So other developers won't wind up with one developer's settings.所以其他开发人员不会以一个开发人员的设置结束。
  2. So when you view status, or commit files, those files won't clutter the code base and obscure new files you need to add.因此,当您查看状态或提交文件时,这些文件不会使代码库变得混乱,也不会掩盖您需要添加的新文件。

We don't commit the binary file (*.suo), but we commit the .user file.我们不提交二进制文件 (*.suo),但我们提交 .user 文件。 The .user file contains for example the start options for debugging the project. .user 文件包含例如用于调试项目的启动选项。 You can find the start options in the properties of the project in the tab "Debug".您可以在“调试”选项卡的项目属性中找到启动选项。 We used NUnit in some projects and configured the nunit-gui.exe as the start option for the project.我们在一些项目中使用了 NUnit,并配置了 nunit-gui.exe 作为项目的启动选项。 Without the .user file, each team member would have to configure it separately.如果没有 .user 文件,每个团队成员都必须单独配置它。

Hope this helps.希望这可以帮助。

Since I found this question/answer through Google in 2011, I thought I'd take a second and add the link for the *.SDF files created by Visual Studio 2010 to the list of files that probably should not be added to version control (the IDE will re-create them).由于我在 2011 年通过 Google 找到了这个问题/答案,我想我需要花点时间将 Visual Studio 2010 创建的 *.SDF 文件的链接添加到可能不应该添加到版本控制的文件列表中( IDE 将重新创建它们)。 Since I wasn't sure that a *.sdf file may have a legitimate use elsewhere, I only ignored the specific [projectname].sdf file from SVN.由于我不确定 *.sdf 文件是否可以在其他地方合法使用,因此我只忽略了来自 SVN 的特定 [projectname].sdf 文件。

Why does the Visual Studio conversion wizard 2010 create a massive SDF database file?为什么 Visual Studio 转换向导 2010 会创建海量 SDF 数据库文件?

No, you should not add them to source control since - as you said - they're user specific.不,您不应该将它们添加到源代码管理中,因为 - 正如您所说 - 它们是特定于用户的。

SUO (Solution User Options): Records all of the options that you might associate with your solution so that each time you open it, it includes customizations that you have made. SUO(解决方案用户选项):记录您可能与您的解决方案关联的所有选项,以便每次打开它时都包含您所做的自定义。

The .user file contains the user options for the project (while SUO is for the solution) and extends the project file name (eg anything.csproj.user contains user settings for the anything.csproj project). .user 文件包含项目的用户选项(而 SUO 用于解决方案)并扩展项目文件名(例如,anything.csproj.user 包含 any.csproj 项目的用户设置)。

This appears to be Microsoft's opinion on the matter:这似乎是微软对此事的看法:

Adding (and editing) .suo files to source control 添加(和编辑).suo 文件到源代码管理

I don't know why your project stores the DebuggingWorkingDirectory in the suo file.不知道你的项目为什么把DebuggingWorkingDirectory 存储在suo 文件中。 If that is a user specific setting you should consider storing that in the *.proj.user filename.如果这是用户特定的设置,您应该考虑将其存储在 *.proj.user 文件名中。 If that setting is shareable between all users working on the project you should consider storing it in the project file itself.如果该设置可在处理项目的所有用户之间共享,则应考虑将其存储在项目文件本身中。

Don't even think of adding the suo file to source control!甚至不要考虑将 suo 文件添加到源代码管理中! The SUO (soluton user options) file is meant to contain user-specific settings, and should not be shared amongst users working on the same solution. SUO(解决方案用户选项)文件旨在包含特定于用户的设置,不应在使用同一解决方案的用户之间共享。 If you'd be adding the suo file in the scc database I don't know what other things in the IDE you'd break, but from source control point of view you will break web projects scc integration, the Lan vs Internet plugin used by different users for VSS access, and you could even cause the scc to break completely (VSS database path stored in suo file that may be valid for you may not be valid for another user).如果您要在 scc 数据库中添加 suo 文件,我不知道您会破坏 IDE 中的其他哪些内容,但是从源代码控制的角度来看,您将破坏 web 项目 scc 集成,使用的 Lan vs Internet 插件由不同的用户进行 VSS 访问,您甚至可能导致 scc 完全中断(存储在 suo 文件中的 VSS 数据库路径可能对您有效,但对其他用户可能无效)。

Alin Constantin (MSFT)阿林·康斯坦丁 (MSFT)

By default Microsoft's Visual SourceSafe does not include these files in the source control because they are user-specific settings files.默认情况下,Microsoft 的 Visual SourceSafe 不将这些文件包含在源代码管理中,因为它们是特定于用户的设置文件。 I would follow that model if you're using SVN as source control.如果您使用 SVN 作为源代码管理,我会遵循该模型。

Visual Studio will automatically create them. Visual Studio 将自动创建它们。 I don't recommend putting them in source control.我不建议将它们置于源代码管理中。 There have been numerous times where a local developer's SOU file was causing VS to behave erratically on that developers box.有很多次本地开发人员的 SOU 文件导致 VS 在该开发人员框上表现不正常。 Deleting the file and then letting VS recreate it always fixed the issues.删除文件然后让 VS 重新创建它总是可以解决问题。

On the MSDN website , it clearly states thatMSDN 网站上,它明确指出

The solution user options (.suo) file contains per-user solution options.解决方案用户选项 (.suo) 文件包含每个用户的解决方案选项。 This file should not be checked in to source code control .此文件不应签入源代码控制

So I'd say it is pretty safe to ignore these files while checking in stuff to your source control.所以我会说在将内容签入源代码管理时忽略这些文件是非常安全的。

No.不。

I just wanted a real short answer, and there wasn't any.我只是想要一个真正简短的答案,但没有。

I wouldn't.我不会。 Anything that could change per "user" is usually not good in source control.任何可以根据“用户”更改的内容通常都不适用于源代码控制。 .suo, .user, obj/bin directories .suo、.user、obj/bin 目录

These files are user-specific options, which should be independent of the solution itself.这些文件是用户特定的选项,应该独立于解决方案本身。 Visual Studio will create new ones as necessary, so they do not need to be checked in to source control. Visual Studio 将根据需要创建新的,因此不需要将它们签入源代码管理。 Indeed, it would probably be better not to as this allows individual developers to customize their environment as they see fit.事实上,最好不要这样做,因为这允许个人开发人员按照他们认为合适的方式自定义他们的环境。

They contain the specific settings about the project that are typically assigned to a single developer (like, for example, the starting project and starting page to start when you debug your application).它们包含有关项目的特定设置,这些设置通常分配给单个开发人员(例如,调试应用程序时的起始项目和起始页面)。

So it's better not adding them to version control, leaving VS recreate them so that each developer can have the specific settings they want.所以最好不要将它们添加到版本控制中,让 VS 重新创建它们,以便每个开发人员都可以拥有他们想要的特定设置。

You cannot source-control the .user files, because that's user specific.您不能对 .user 文件进行源代码控制,因为这是特定于用户的。 It contains the name of remote machine and other user-dependent things.它包含远程机器的名称和其他用户相关的东西。 It's a vcproj related file.这是一个与vcproj相关的文件。

The .suo file is a sln related file and it contains the "solution user options" (startup project(s), windows position (what's docked and where, what's floating), etc.) .suo 文件是一个与 sln 相关的文件,它包含“解决方案用户选项”(启动项目、窗口位置(停靠的位置、位置、浮动的位置)等)

It's a binary file, and I don't know if it contains something "user related".这是一个二进制文件,我不知道它是否包含“用户相关”的内容。

In our company we do not take those files under source control.在我们公司,我们不会将这些文件置于源代码控制之下。

.user is the user settings, and I think .suo is the solution user options. .user 是用户设置,我认为 .suo 是解决方案用户选项。 You don't want these files under source control;您不希望这些文件受到源代码控制; they will be re-created for each user.它们将为每个用户重新创建。

Don't add any of those files into version control.不要将任何这些文件添加到版本控制中。 These files are auto generated with work station specific information, if checked-in to version control that will cause trouble in other work stations.这些文件是使用工作站特定信息自动生成的,如果签入版本控制会导致其他工作站出现问题。

Using Rational ClearCase the answer is no.使用 Rational ClearCase的答案是否定的。 Only the .sln & .*proj should be registered in source code control.只有 .sln 和 .*proj 应该在源代码控制中注册。

I can't answer for other vendors.我无法回答其他供应商。 If I recall correctly, these files are "user" specific options, your environment.如果我没记错的话,这些文件是“用户”特定的选项,您的环境。

No, they shouldn't be committed to source control as they are developer/machine-specific local settings.不,它们不应该致力于源代码控制,因为它们是开发人员/机器特定的本地设置。

GitHub maintain a list of suggested file types for Visual Studio users to ignore at https://github.com/github/gitignore/blob/master/VisualStudio.gitignore GitHub 在https://github.com/github/gitignore/blob/master/VisualStudio.gitignore上维护了一个建议文件类型列表,供 Visual Studio 用户忽略

For svn, I have the following global-ignore property set:对于 svn,我设置了以下global-ignore属性:

*.DotSettings.User *.DotSettings.User
*.onetoc2 *.onetoc2
*.suo *.suo
.vs .vs
PrecompiledWeb预编译网页
thumbs.db大拇指数据库
obj对象
bin垃圾桶
debug调试
*.user *。用户
*.vshost.* *.vshost.*
*.tss *.tss
*.dbml.layout *.dbml.layout

Others have explained that no, you don't want this in version control.其他人解释说不,您不希望在版本控制中使用它。 You should configure your version control system to ignore the file (eg via a .gitignore file).您应该配置您的版本控制系统以忽略该文件(例如,通过.gitignore文件)。

To really understand why, it helps to see what's actually in this file.要真正理解原因,查看此文件中的实际内容会有所帮助。 I wrote a command line tool that lets you see the .suo file's contents.我编写了一个命令行工具,可以让您查看.suo文件的内容。

Install it on your machine via:通过以下方式将其安装在您的机器上:

dotnet tool install -g suo

It has two sub-commands, keys and view .它有两个子命令, keysview

suo keys <path-to-suo-file>

This will dump out the key for each value in the file.这将转储文件中每个值的键。 For example (abridged):例如(略):

nuget
ProjInfoEx
BookmarkState
DebuggerWatches
HiddenSlnFolders
ObjMgrContentsV8
UnloadedProjects
ClassViewContents
OutliningStateDir
ProjExplorerState
TaskListShortcuts
XmlPackageOptions
BackgroundLoadData
DebuggerExceptions
DebuggerFindSource
DebuggerFindSymbol
ILSpy-234190A6EE66
MRU Solution Files
UnloadedProjectsEx
ApplicationInsights
DebuggerBreakpoints
OutliningStateV1674
...

As you can see, lots of IDE features use this file to store their state.如您所见,许多 IDE 功能使用此文件来存储它们的状态。

Use the view command to see a given key's value.使用view命令查看给定键的值。 For example:例如:

$ suo view nuget --format=utf8 .suo
nuget

?{"WindowSettings":{"project:MyProject":{"SourceRepository":"nuget.org","ShowPreviewWindow":false,"ShowDeprecatedFrameworkWindow":true,"RemoveDependencies":false,"ForceRemove":false,"IncludePrerelease":false,"SelectedFilter":"UpdatesAvailable","DependencyBehavior":"Lowest","FileConflictAction":"PromptUser","OptionsExpanded":false,"SortPropertyName":"ProjectName","SortDirection":"Ascending"}}}

More information on the tool here: https://github.com/drewnoakes/suo有关该工具的更多信息,请访问: https : //github.com/drewnoakes/suo

If you set your executable dir dependencies in ProjectProperties>Debugging>Environment , the paths are stored in '.user' files.如果您在ProjectProperties>Debugging>Environment 中设置可执行目录依赖项,路径将存储在“.user”文件中。

Suppose I set this string in above-mentioned field: "PATH=C:\\xyz\\bin" This is how it will get stored in '.user' file:假设我在上面提到的字段中设置了这个字符串: “PATH=C:\\xyz\\bin”这是它如何存储在“.user”文件中:

<LocalDebuggerEnvironment>PATH=C:\\xyz\\bin$(LocalDebuggerEnvironment)</LocalDebuggerEnvironment>

This helped us a lot while working in OpenCV.这对我们在 OpenCV 中工作有很大帮助。 We could use different versions of OpenCV for different projects.我们可以为不同的项目使用不同版本的 OpenCV。 Another advantage is, it was very easy to set up our projects on a new machine.另一个优势是,在新机器上设置我们的项目非常容易。 We just had to copy corresponding dependency dirs.我们只需要复制相应的依赖目录。 So for some projects, I prefer to add the '.user' to source control.所以对于某些项目,我更喜欢将“.user”添加到源代码管理中。

Even though, it is entirely dependent on projects.尽管如此,它完全依赖于项目。 You can take a call based on your needs.您可以根据需要接听电话。

As explained in other answers, both .suo and .user shouldn't be added to source control, since they are user/machine-specific (BTW .suo for newest versions of VS was moved into dedicated temporary directory .vs , which should be kept out of source control completely).正如其他答案中所解释的, .suo.user都不应该添加到源代码管理中,因为它们是特定于用户/机器的(顺便说一句,最新版本的 VS 的.suo已移入专用临时目录.vs ,这应该是完全脱离源代码控制)。

However if your application requires some setup of environment for debugging in VS (such settings are usually kept in .user file), it may be handy to prepare a sample file (naming it like .user.SAMPLE ) and add it to source control for references.但是,如果您的应用程序需要一些环境设置以在 VS 中进行调试(此类设置通常保存在.user文件中),则准备一个示例文件(将其命名为.user.SAMPLE )并将其添加到源代码控制中可能会很方便参考。

Instead of hard-coded absolute path in such file, it makes sense to use relative ones or rely on environment variables, so the sample may be generic enough to be easily re-usable by others.代替此类文件中的硬编码绝对路径,使用相对路径或依赖环境变量是有意义的,因此示例可能足够通用以易于其他人重用。

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

相关问题 Visual Studio.suo 和.dll? - Visual Studio .suo and .dll? Visual Studio 2013开发中添加(它将文件添加到项目中,但不在源代码管理中) - Visual Studio 2013 Add in development (it adds files to a project but not in source control) Visual Studio 2015 TFS将文件添加到源代码管理 - Visual studio 2015 tfs add files to source control Visual Studio SUO文件的文件格式或解析指南。 - File format or parsing guidance for Visual Studio SUO files. Visual Studio 2008 - 移动解决方案文件(sln,suo) - Visual Studio 2008 - Moving solution files (sln, suo) 如何使用Visual Studio查找不在TFS源代码管理中的文件? - How can I find files not in TFS source control with Visual Studio? 如何在Visual Studio的SVN中取消.suo文件的版本? - How do I unversion an .suo file in SVN for Visual Studio? 我应该将.vcxproj.filter文件添加到源代码管理中吗? - Should I add .vcxproj.filter files to source control? Visual Studio项目文件和源代码控制绑定 - Visual Studio Project Files and Source Control Bindings Visual Studio SUO文件破解应用程序 - Visual Studio SUO file breaking application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM