Unity Failing to Generate Visual Studio Solution Files

I am using Visual Studio 2015 with Unity Pro and have created a quick project to teach some students Unity. When I create a simple C# script file and attempt to edit the file Unity launches Visual Studio as you would expect. Everything breaks after that.

I am getting an error when opening Visual Studio staying UnityVS.Project.sln can’t be found. This file does not exist in the directory where I am working so this makes sense. When I use the Sync MonoDevelop Project menu item under Assets -> Sync MonoDevelop Project I get the same error.

If I navigate to the project folder in Explorer I see two generated Solutions and two related projects. There are:

  • Project.sln
  • Project-csharp.sln
  • Assembly-CSharp-Editor.csproj
  • Assembly-CSharp-Editor-vs.csproj

If I open the generated C# script file and edit it Unity does see the edits. I guess this means I can continue to work on my project, I just can’t use any of the connectivity features between Unity and my VS Solutions.

Is there a way to make Unity correctly generate solutions?

Note that I have replaced the name of my project with “Project” in the file names I mentioned above.

Right so here is how to fix this problem. There was apparently a breaking change introduced to Unity recently that changes how the workflow with Visual Studio works. You can no longer simply open the project in Visual Studio as if it were MonoDevelop. Even if you have the Visual Studio Tools for Unity plugin installed in Visual Studio it still will not work.

You will need the tools for Visual Studio for Unity installed in Visual Studio and you will need the Visual Studio 2015 Tools package from the Unity Asset Store. Failing either of these appears to result in the problem I described above. Once you have downloaded the package from the asset store everything will clear itself up.

If Assets → “Open C# Project” doesn’t create the .sln file, try updating your external tools preferences.

In Unity, go to Edit → Preferences, and make sure that Visual Studio is selected as your preferred external editor.
Also, make sure that “Generate all .csproj files” is on.