35

Is it possible to make a solution in VS depend on (i.e. include) an entire other solution? I've seen some stuff about "Solution Folders", but these don't seem to be the same thing....? Thanks! (BTW, I'm using VS 2008)

Robert Fraser
  • 10,649
  • 8
  • 69
  • 93

5 Answers5

21

Not really. You'd have to do one of the following:

  • Make a build script that builds the solutions in the correct order.
  • Pre-build solution A, and only reference the built binary outputs from it in solution B.
  • Make a third solution containing all of the projects from both solutions.

The first two items are the most common, where I personally prefer the second.

Sam Harwell
  • 97,721
  • 20
  • 209
  • 280
  • But see the answer from net_prog – Jon Coombs Feb 23 '14 at 03:06
  • It looks like this [actually](https://stackoverflow.com/a/826009/712526) [was possible](https://msdn.microsoft.com/en-us/library/ee817674.aspx) in 2009. At any rate, I hope it's gotten better in 2015. – jpaugh Jun 16 '17 at 14:42
17

This post is old, but these days you can easily reuse dependencies in other solutions by building nuget packages for all of them. VS 2015 has nuget package building built in but is currently a Release Candidate. In Visual Studio 2013 you can use the Nuget.Packaging nuget package to allow your project to build as a Nuget Package.

Then you can just publish new versions of your packages to a local network share and configure it as a Repository in Visual Studio.

Then your other solution's projects can depend on that package.

For example, say you have a reusable Utility DLL in a Solution Called "Core Framework" and you want to use a utility in there on a WebSite you are building in a solution called "XYZEcosystem".

In the CoreFramework solution you would build a nuget package for the Utility Project that compiles to the utility dll and include the dll and it's pdb file in the package.

Then you publish that to your network share.

So let's say your package has an ID like "XYZ.Core.Utilities" with a version of 1.0.0.0.

Now in XYZEcosystem you would use the package manager console, set the repository drop down to your repository and type "Install-Package XYZ.Core.Utilities" and it will install the latest version of XYZ.Core.Utilities.

If you make a change to XYZ.Core.Utilities you can run Update-Package XYZ.Core.Utilities on XYZEcosystem and it will pick up the new version.

Ryan Mann
  • 5,178
  • 32
  • 42
8

Take a look here: https://learn.microsoft.com/en-us/archive/blogs/habibh/walkthrough-adding-an-existing-visual-studio-solution-to-another-solution

Actually the method described adds all projects from another solution to the current solution, not quite what we want, but at least this saves time adding all of the projects manually one by one.

M H
  • 325
  • 3
  • 8
net_prog
  • 9,921
  • 16
  • 55
  • 70
  • I checked and this still works with VS 2019, but the added `*.sln` file is not referenced by the superordinate `*.sln` file. So any changes made to the added `*.sln` file will not be reflected in the superordinate `*.sln` file. It would be better if the `*.sln` files could maintain a hierarchical relationship. – A. David Ing Jan 27 '21 at 22:51
0

A solution is a collection of assemblies that build to create some kind of executable or dll. Having one solution depend on another does not make sense. The output assembly (executable/dll) depends on the assemblies that it references. If your solution depends on other assemblies, then reference them. You can add projects to your solution (File>Add>Existing Project) and then you can add refences these projects from your output project.

darasd
  • 2,899
  • 3
  • 26
  • 39
0

You cannot do that. And why would you want to?

Simply add all the projects that you depend on (the projects in the 'other' solution) to the solution.

Then use project references (not file references) between the projects.

codeape
  • 97,830
  • 24
  • 159
  • 188
  • 3
    I want to depend on another solution for which I don't have control. If that solution gets updated to include another project, I want that automatically taken into account. – Robert Fraser Jul 20 '09 at 10:14
  • 1
    In that case, either: Create a script that automatically generates your solution file. Or manually add projects to your solution, and create a script that validates that all projects are in the solution. Solution files are simple text files with a fairly simple structure. – codeape Jul 20 '09 at 10:30
  • One would want to if the dependency tree was deep and complex, although a mechanism outside VS that makes sure dependent dlls are up to date and in the right location would save a lot of compile time if those dlls are available in a central controlled repository. – Denise Skidmore Jan 31 '18 at 16:50