How do I add scripts from a separate Unity project into my VS solution?

I am working on a Multiplayer game. This game utilizes two separate Unity Projects (GameClient and GameServer) in order to function. As you would expect, each of these projects contains unique scripts.

However, because there are two separate projects, Unity has generated two separate solution files:

  • GameClient.sln
  • GameServer.sln

This means that I must run two separate instances of Visual Studio to work on my project (one containing the GameClient scripts, and the other containing the GameServer scripts.

To streamline my workflow, and reduce the possibility of errors (via mistaking which .sln was selected), I’d like to merge both .csproj files into one VS Solution and have Unity open this “master .sln” file when I open a script within Unity.

Is there a way to override which .sln file Unity opens when opening a script?

If not, is there a way to include the .csproj files from the other projects into each solution (this way, I’d have two solutions but each would have visibility into all the files).

Hopefully I’m explaining my dilemma well. Thanks!

In case anyone searches for this in the future, I found a solution:


Open both .sln files in an editor (I used VSCode). Find where the environment iterates through Project persistence blocks, and copy relevant persistence block from each .sln file and paste each into the other .sln file. In my case, this meant copying:

Project("{FAE14EC0-301F-11D3-BF4B-00C04F79AFBC}") = "Assembly-C-Sharp", "Assembly-CSharp.csproj", "{74BD5278-4F4A-94F6-630E-8B98EDA9781F}"
EndProject

from my GameServer.sln file and pasting into the same location in my GameClient.sln file. I then did the same for the Client .sln into the Server .sln file.


Once that’s done, we need to add a relative path to our project location, otherwise the .sln cannot locate it. Since my Unity Projects shared the same parent directory (the highest folder in my Git repository), this was a simple adjustment for both files:

ex from GameClient.sln:

Project("{FAE14EC0-301F-11D3-BF4B-00C04F79AFBC}") = "Assembly-C-Sharp", "../GameServer/Assembly-CSharp.csproj", "{74BD5278-4F4A-94F6-630E-8B98EDA9781F}"
EndProject

Note the addition of …/GameServer. The …/ navigates to the parent directory of the .sln file, and then I navigate down into my other Unity Project (/GameServer).


Last, I renamed each file so that it would be easier to recognize which project was which in my Solution Explorer:

Project("{FAE14EC0-301F-11D3-BF4B-00C04F79AFBC}") = "Server", "../GameServer/SERVER.csproj", "{74BD5278-4F4A-94F6-630E-8B98EDA9781F}"
EndProject

And now it works! I can see Scripts from both unity projects, as well as my library of shared scripts (cam.corelibrary) all in one instance of Visual Studio saving me a lot of alt-tabbing and potential mistakes.

alt text