Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should a .sln be committed to source control?

Is it a best practice to commit a .sln file to source control? When is it appropriate or inappropriate to do so?

Update There were several good points made in the answers. Thanks for the responses!

like image 415
jlembke Avatar asked Jun 23 '09 16:06

jlembke


People also ask

Should .user files be in source control?

The solution user options (. suo) file contains per-user solution options. This file should not be checked in to source code control.

Do we commit Csproj file?

You should commit the . sln and the . csproj , but not the . suo or the .


3 Answers

I think it's clear from the other answers that solution files are useful and should be committed, even if they're not used for official builds. They're handy to have for anyone using Visual Studio features like Go To Definition/Declaration.

By default, they don't contain absolute paths or any other machine-specific artifacts. (Unfortunately, some add-in tools don't properly maintain this property, for instance, AMD CodeAnalyst.) If you're careful to use relative paths in your project files (both C++ and C#), they'll be machine-independent too.

Probably the more useful question is: what files should you exclude? Here's the content of my .gitignore file for my VS 2008 projects:

*.suo
*.user
*.ncb
Debug/
Release/
CodeAnalyst/

(The last entry is just for the AMD CodeAnalyst profiler.)

For VS 2010, you should also exclude the following:

ipch/
*.sdf
*.opensdf
like image 177
Trevor Robinson Avatar answered Oct 17 '22 16:10

Trevor Robinson


Yes -- I think it's always appropriate. User specific settings are in other files.

like image 61
Lou Franco Avatar answered Oct 17 '22 15:10

Lou Franco


Yes you should do this. A solution file contains only information about the overall structure of your solution. The information is global to the solution and is likely common to all developers in your project.

It doesn't contain any user specific settings.

like image 21
JaredPar Avatar answered Oct 17 '22 15:10

JaredPar