How do you share code between projects/solutions in Visual Studio?
A project can be referenced by multiple solutions.
Put your library or core code into one project, then reference that project in both solutions.
You can include a project in more than one solution. I don't think a project has a concept of which solution it's part of. However, another alternative is to make the first solution build to some well-known place, and reference the compiled binaries. This has the disadvantage that you'll need to do a bit of work if you want to reference different versions based on whether you're building in release or debug configurations.
I don't believe you can make one solution actually depend on another, but you can perform your automated builds in an appropriate order via custom scripts. Basically treat your common library as if it were another third party dependency like NUnit etc.
File > Add > Existing Project...
will let you add projects to your current solution. Just adding this since none of the above posts point that out. This lets you include the same project in multiple solutions.
You can "link" a code file between two projects. Right click your project, choose Add
-> Existing item
, and then click the down arrow next to the Add
button:
In my experience linking is simpler than creating a library. Linked code results in a single executable with a single version.