Should a .sln be committed to source control?

2019-01-31 10:49发布

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!

16条回答
欢心
2楼-- · 2019-01-31 11:16

Yes, things you should commit are:

  • solution (*.sln),
  • project files,
  • all source files,
  • app config files
  • build scripts

Things you should not commit are:

  • solution user options (.suo) files,
  • build generated files (e.g. using a build script) [Edit:] - only if all necessary build scripts and tools are available under version control (to ensure builds are authentic in cvs history)

Regarding other automatically generated files, there is a separate thread.

查看更多
走好不送
3楼-- · 2019-01-31 11:17

1) Create a new project in VS
2) Right click on the solution in Solution Explorer, select Add to Source Control

Is the sln added to source control? That's your answer.

查看更多
家丑人穷心不美
4楼-- · 2019-01-31 11:22

I generally agree that solution files should be checked in, however, at the company I work for we have done something different. We have a fairly large repository and developers work on different parts of the system from time to time. To support the way we work we would either have one big solution file or several smaller. Both of these have a few shortcomings and require manual work on the developers part. To avoid this, we have made a plug-in that handles all that.

The plug-in let each developer check out a subset of the source tree to work on simply by selecting the relevant projects from the repository. The plugin then generates a solution file and modifies project files on the fly for the given solution. It also handles references. In other words, all the developer has to do is to select the appropriate projects and then the necessary files are generated/modified. This also allows us to customize various other settings to ensure company standards.

Additionally we use the plug-in to support various check-in policies, which generally prevents users from submitting faulty/non-compliant code to the repository.

查看更多
Juvenile、少年°
5楼-- · 2019-01-31 11:22

Yes - Everything used to generate your product should be in source control.

查看更多
Juvenile、少年°
6楼-- · 2019-01-31 11:23

Yes, you always want to include the .sln file, it includes the links to all the projects that are in the solution.

查看更多
SAY GOODBYE
7楼-- · 2019-01-31 11:23

Under most circumstances, it's a good idea to commit .sln files to source control.

If your .sln files are generated by another tool (such as CMake) then it's probably inappropriate to put them into source control.

查看更多
登录 后发表回答