- Home /
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.
I have tested this by creating multiple additional Unity projects with a single C# script. All are failing in identical fashion.
Are you using Visual Studio Tools? it should generate new solution (if it's missing) at start as far as I know
@Positive7 I am using Visual Studio 2015 Tools for Unity v2.0.0. I just ran the repair tool. This had no effect and I'm still encountering the error. Perhaps it's a bug in version 2?
I'm using 2.0.0 too and never had this issue. I tried to delete my *.sln then open VS from Unity -> Visual Studio Tools -> Open in Visual Studio
and it recreated the solution. Try to Generate Project files from Unity -> Visual Studio Tools -> Generate Project Files
Also check it in Configuration if Generate Solution Files
checked
Alright, I figured it out. I'll post an answer regarding the fix. Having the Tools installed in Visual Studio is not enough and there was apparently a breaking change made that requires you to download a separate asset package from the Asset Store to use Visual Studio. Failing to do that results in the error I receive.
For an engine which prides itself on usability, these are the things I'd expect them to avoid...
Anyway, thank you for your help!
Answer by Runewake · Sep 04, 2015 at 10:35 PM
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.
Yeah you should always Import UnityVS (Visual Studio Tools 2015) upon starting a New Project :D
That's strange, i have neither of both (tools/plugins) and it works just fine (since I went back to Windows 7). But I can remember the problem, it always occured when i still had Windows 8 on my laptop.
@Suddoha Perhaps this is the result of having one and not the other or a specific version of Windows?
Answer by cowlinator · May 17, 2020 at 07:04 AM
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.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Warning with Unity 2018.1.3 and Visual Studio 2017 1 Answer
Creating new C# script in unity not being added in VS's solution 3 Answers
vector 3 isnt working offset part,the vector 3 isnt working 'offset' has a problem 2 Answers