45

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?

Sam Harwell
  • 97,721
  • 20
  • 209
  • 280
Kai
  • 3,997
  • 4
  • 30
  • 36
  • The sln is the solution file, the csproj is the c# project file. You will need both of these files. The suo is the solution user options file and as the name suggests you don't want that file. It just contains user options. Also all *.csproj.* files can also be ignored. – mrsheen Apr 27 '12 at 15:58
  • http://msdn.microsoft.com/en-us/library/ee817674.aspx Explicit list from Microsoft there. – JMD Oct 30 '13 at 22:26

11 Answers11

43

Dont include
bin
obj
*.suo
*.user
_Resharper* (if you have Resharper)

Include
*.sln
*.csproj

You can also check the .gitignore file for visual studio projects on github.

Carl Bergquist
  • 3,894
  • 2
  • 25
  • 42
15

.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*
Agent_9191
  • 7,216
  • 5
  • 33
  • 57
13

Shouldn't be versioned:

  • .csproj.user is the user's project file settings (e.g. startup project)
  • .suo is the user's solution file settings

Should be versioned:

  • .sln is the solution file itself (what projects it contains etc)
  • .csproj is the project file

I'm not sure about "contentproj" but it sounds like it's a project file which should be under svn.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
6

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.

twk
  • 3,122
  • 2
  • 26
  • 36
1

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.

leppie
  • 115,091
  • 17
  • 196
  • 297
0

Needed...

*.sln - The solution file contains references to all the projects and dependencies between the projects.
*.csproj - The project files themselves. These tell what files are included in the project, references, and the build steps for the project.

Not...

*.suo - This is a user settings file...

Restore the Data Dumps
  • 38,967
  • 12
  • 96
  • 122
0

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.

Gabriel Magana
  • 4,338
  • 24
  • 23
0

I leave out the Visual Studio Solution User Options file (*.suo) and the binaries directories as they get recompiled everytime you build your solution (the bin and obj folders).

Sam Harwell
  • 97,721
  • 20
  • 209
  • 280
Albireo
  • 10,977
  • 13
  • 62
  • 96
0

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

Pac0
  • 21,465
  • 8
  • 65
  • 74
-1

We also work with Visual Studio C# and SVN and I don't know about all the project files, but we only exclude the complete bin directory.

MysticEarth
  • 2,646
  • 4
  • 33
  • 53
-1

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.

Nathan Smith
  • 8,271
  • 3
  • 27
  • 44