Visual Studio解决方案包含两种类型的隐藏用户文件。一个是解决方案。suo文件,这是一个二进制文件。另一个是project .user文件,它是一个文本文件。这些文件到底包含哪些数据?
我也一直在考虑是否应该将这些文件添加到源代码控制(在我的情况下是Subversion)。如果我没有添加这些文件,而另一个开发人员签出了解决方案,Visual Studio会自动创建新的用户文件吗?
Visual Studio解决方案包含两种类型的隐藏用户文件。一个是解决方案。suo文件,这是一个二进制文件。另一个是project .user文件,它是一个文本文件。这些文件到底包含哪些数据?
我也一直在考虑是否应该将这些文件添加到源代码控制(在我的情况下是Subversion)。如果我没有添加这些文件,而另一个开发人员签出了解决方案,Visual Studio会自动创建新的用户文件吗?
当前回答
这些文件是特定于用户的选项,应该独立于解决方案本身。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. Also, VS will change it almost every time you execute it, so it will always be marked by the SCM as 'changed'. I don't include either, I'm in a project using VS for 2 years and had no problems doing that. 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'.
你不需要添加这些——它们包含每个用户的设置,其他开发人员不会想要你的副本。
不要将这些文件添加到版本控制中。这些文件是自动生成的,包含特定于工作站的信息,如果签入到版本控制,将在其他工作站引起麻烦。
Visual Studio会自动创建它们。我不建议把它们放在源代码控制中。曾经有很多次,本地开发人员的SOU文件导致VS在开发人员的盒子上表现不稳定。删除文件,然后让VS重新创建它总是修复问题。
其他人解释说,不,你不希望在版本控制中使用这个。你应该配置你的版本控制系统来忽略这个文件(例如通过一个.gitignore文件)。
要真正理解其中的原因,看看这个文件中到底有什么会有所帮助。我编写了一个命令行工具,可以让您查看.suo文件的内容。
在你的机器上安装它通过:
dotnet tool install -g suo
它有两个子命令,键和视图。
suo keys <path-to-suo-file>
这将转储文件中每个值的键。例如(节选):
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
...
如您所见,许多IDE特性都使用这个文件来存储它们的状态。
使用view命令查看给定键的值。例如:
$ 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"}}}
有关该工具的更多信息,请访问:https://github.com/drewnoakes/suo