Should a .sln be committed to source control?

后端 未结 15 1475
时光说笑
时光说笑 2020-12-23 20:17

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 poin

15条回答
  •  死守一世寂寞
    2020-12-23 20:52

    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
    

提交回复
热议问题