Walkthrough: Adding an existing Visual Studio solution to another solution

Often, developers partition their applications into separate Visual Studio solutions in order to make managing the complexity of the overall application easier. Sometimes, the reverse is true. That is, you may want to combine several existing solutions into one master solution. The reason for doing this may be to make it easier to navigate between the different files in different solutions or perhaps make the build process for the overall application more manageable.

One of the little known facts of Visual Studio is that you can add an existing solution to another solution, without impacting the existing solution. Let's assume for this exercise that you want to add the Engine solution to the Robot solution.

The first step is to create a "Solution Folder" in the the Robot solution. Give the Solution Folder the same name as the the solution that you're adding, in this case "Engine". The reason for crating a Solution Folder is that it acts as a container for all of the projects in the Engine solution. Otherwise, the projects in the Engine solution would be mixed with projects from the Robot solution.

Add New Solution Folder

Once you’ve created the "Engine" Solution Folder in the Robot solution, right-click the folder and select the Add –> Existing Project... command. In the Add Existing Project dialog, change the file type to "Solution (*.sln) to see the solution file, i.e. Engine.sln.

 Add Existing Project dialog

Once you’ve added the Engine solution, the Robot solution will now contain the projects from the Engine solution, as shown below. The nice thing about this approach is that not only are all the projects now in one solution but at any time, you can open the separate solutions without impacting the "master" solution and vice versa.

Solution Explorer showing the combined solutions

Below is a screenshot of a real world example after eight solutions have been combined into one. The "master" solution contains eight other solutions. You can see that "DinnerNow – Main" contains 31 project, even though these projects are part of other solutions.

Solution Explorer showing DinnerNow solution 

Habib Heydarian.

Skip to main content