Should a .sln be committed to source control?

jlembke picture jlembke · Jun 23, 2009 · Viewed 27.4k times · Source

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!

Answer

Trevor Robinson picture Trevor Robinson · Jun 23, 2009

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