Which files in a Visual C# Studio project don'

2019-01-07 08:49发布

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).

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?

Some suspect files:

  • project.csproj
  • project.csproj.Debug.cachefile
  • project.csproj.user
  • project.sln
  • project.suo
  • Content\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?

11条回答
放荡不羁爱自由
2楼-- · 2019-01-07 08:58

Check this out - type visualstudio amd 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.

查看更多
家丑人穷心不美
3楼-- · 2019-01-07 09:01

The .sln file defines your solution together with the .proj files (one for each project), so keep them in your 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.

查看更多
狗以群分
4楼-- · 2019-01-07 09:05

.csproj defines the project structure. It is vital.

This is what I add to my global ignore list in Tortoise SVN:

*.suo *.user bin obj *.pdb *.cache *_svn *.svn *.suo *.user *.build-res TestResults _ReSharper*
查看更多
Fickle 薄情
5楼-- · 2019-01-07 09:07

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.

查看更多
我命由我不由天
6楼-- · 2019-01-07 09:11

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.

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.

Example .gitignore for Unity 3D : https://github.com/github/gitignore/blob/master/Unity.gitignore

查看更多
forever°为你锁心
7楼-- · 2019-01-07 09:12

You definitely need csproj files... You might want to try AnkhSVN or VisualSVN, those VS addins add only the required files to 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.

查看更多
登录 后发表回答