This has probably been posted before, but I\'m not sure what search terms to look for!
Quick explanation.
I have code that is shared between a few projects. This
As others have said, you can simply right-click on your solution in the solution explorer, select Add > Existing Project and browse to the common projects .csproj file and it will be included in the solution from its original location.
There are two problems with this however which may or may not be an issue, depending on the size of your team:
1 - The common project will included in each solution with a relative path to the solution file (IE: ...\CommonProject\Common.csproj). This means all developers have to have the same working file structure or they will get errors when they try to open the main project.
2 - In the scenario there the common project is referenced by multiple projects (say two - A and B) and a developer working on project A has to make changes to to the common project as part of their task. There is no way for that developer to know if the changes they have made will break project B without them actually checking out project B and compiling it. As more and more projects reference the common project, the risk of this happening increases to the point where it becomes unmanageable.
Again, as other's have said, there is no 'correct' way to do this, however the approach I have taken is as follows:
1 - Use continuous integration such as Cruise Control to manage the building of the projects and put the common project as a stand alone project on the server.
2 - Create a directory under your source control to house built common DLL's. Have this directory checked out on your build machine and whenever the common project builds, it copies the output DLL into the DLL folder and commits these changes to source control.
3 - Use environment variables on all developers machines and the build server to control the location of the common DLL folder and reference the DLL's using that variable rather than the hard-coded path. (IE: rather than C:\Source\MyCommonProjectDLLS\Common.dll use $(MyCommonLocation)\Common.dll with the variable 'MyCommonLocation' set to C:\Source\MyCommonProjectDLLS)
4 - For any project which references the common DLL, set up a CI trigger on the build server for that project to watch the common DLL folder. Whenever changes are committed to it, the build server should then build all consuming projects.
This immediately lets you know if you are committing breaking changes for any other project. The only drawback is that, in this model, consuming projects are forces to take updates to the common DLL as soon as they are made. An alternative is to version the Common DLL from the source control revision when it is built, and place each version in its own sub directory under the common DLL folder. So you would end up with:
Common DLLs
-1.0.0.1234
-1.0.0.1235
-1.0.0.1236
And so on. The advantage of this is that each project can then choose when to take updates to the common DLL by simply referencing the new version of the code. However it cuts both ways as this can mean that some projects are left with older versions of the common code for longer than they should, which can increase the work involved when the time comes to final bring in those changes.
Hope this helps.