Reputation: 111
When I try to open a unity script in vscode, I get an error message Some projects have trouble loading. Please review the output for more details.
. When I select Show Output
, I get this output:
Starting OmniSharp server at 7/5/2022, 6:09:26 PM
Target: /Users/angelalindsay/Desktop/Unity Projects/First Unity Game/First Unity Game/First Unity Game.sln
OmniSharp server started with .NET 6.0.301
.
Path: /Users/angelalindsay/.vscode/extensions/ms-dotnettools.csharp-1.25.0-darwin-x64/.omnisharp/1.39.0-net6.0/OmniSharp.dll
PID: 2949
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on Unknown 0.0 (Unknown)
[info]: OmniSharp.Services.DotNetCliService
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
[info]: OmniSharp.Services.DotNetCliService
Using the 'dotnet' on the PATH.
[info]: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 1 MSBuild instance(s)
1: .NET Core SDK 6.0.301 17.2.0 - "/usr/local/share/dotnet/sdk/6.0.301/"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: .NET Core SDK 6.0.301 17.2.0 - "/usr/local/share/dotnet/sdk/6.0.301/"
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.MSBuild.ProjectSystem
Detecting projects in '/Users/angelalindsay/Desktop/Unity Projects/First Unity Game/First Unity Game/First Unity Game.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for '/Users/angelalindsay/Desktop/Unity Projects/First Unity Game/First Unity Game/Assembly-CSharp.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in '/Users/angelalindsay/Desktop/Unity Projects/First Unity Game/First Unity Game'.
[info]: OmniSharp.Script.ScriptProjectSystem
Did not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
Configuration finished.
[info]: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location '/Users/angelalindsay/Desktop/Unity Projects/First Unity Game/First Unity Game' on host 2915.
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: /Users/angelalindsay/Desktop/Unity Projects/First Unity Game/First Unity Game/Assembly-CSharp.csproj
[fail]: OmniSharp.MSBuild.ProjectLoader
This project targets .NET version that requires reference assemblies that are not installed (e.g. .NET Framework). The most common solution is to make sure Mono is fully updated on your machine (https://mono-project.com/download/) and that you are running the .NET Framework build of OmniSharp (e.g. 'omnisharp.useModernNet': false in C# Extension for VS Code).
[warn]: OmniSharp.MSBuild.ProjectManager
Failed to load project file '/Users/angelalindsay/Desktop/Unity Projects/First Unity Game/First Unity Game/Assembly-CSharp.csproj'.
/Users/angelalindsay/Desktop/Unity Projects/First Unity Game/First Unity Game/Assembly-CSharp.csproj
/usr/local/share/dotnet/sdk/6.0.301/Microsoft.Common.CurrentVersion.targets(1221,5): Error: This project targets .NET version that requires reference assemblies that are not installed (e.g. .NET Framework). The most common solution is to make sure Mono is fully updated on your machine (https://mono-project.com/download/) and that you are running the .NET Framework build of OmniSharp (e.g. 'omnisharp.useModernNet': false in C# Extension for VS Code).
[fail]: OmniSharp.MSBuild.ProjectManager
Attempted to update project that is not loaded: /Users/angelalindsay/Desktop/Unity Projects/First Unity Game/First Unity Game/Assembly-CSharp.csproj
[warn]: OmniSharp.Roslyn.CSharp.Services.InlayHints.InlayHintService
Inlay hints requested for document not in workspace Location { FileName = /Users/angelalindsay/Desktop/Unity Projects/First Unity Game/First Unity Game/Assets/Scripts/WayPointFollower.cs, Range = Range { Start = Point { Line = 0, Column = 0 }, End = Point { Line = 21, Column = 0 } } }
[warn]: OmniSharp.Roslyn.CSharp.Services.InlayHints.InlayHintService
Inlay hints requested for document not in workspace Location { FileName = /Users/angelalindsay/Desktop/Unity Projects/First Unity Game/First Unity Game/Assets/Scripts/WayPointFollower.cs, Range = Range { Start = Point { Line = 0, Column = 0 }, End = Point { Line = 21, Column = 0 } } }
I don't know if this is related or not but, the autocomplete for unity is not working in vscode either. I'm able to type code and it works in unity but I would like to have autocomplete and get rid of this error message. Can I fix this? Thanks.
Upvotes: 1
Views: 4969
Reputation: 60
I encountered a similar problem on my Mac and eventually, I managed to fix it by following these steps:
Disable the omnisharp.useModernNet
property by setting it to false.
Remove all C#-related extensions and reset all settings.
Repeat step 1 by setting omnisharp.useModernNet
to false again.
After performing these steps, the problem was resolved!
It's worth noting that during a previous occurrence of this issue, I simply had to reinstall the C# extension requirements. For Windows, this involved installing the .NET Framework and MSBuild Tools, while for macOS/Linux, it required Mono with MSBuild.
MSBuild Tools(windows): https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022
I hope this explanation proves helpful to others experiencing a similar problem.
Upvotes: 0
Reputation: 1781
The problem as the console says (thanks for pointing me to check omnisharp's console) is that you don't have the version of .NET which the omnisharp
plugin expects.
I solved the issue by installing older version of the extension as mu project was using .NET 5 and the updated version of the extension was searching for .NET 6.
I am not sure if you can set the .NET version per project - probably but didn't find a way.
Upvotes: 0
Reputation: 10137
This project targets .NET version that requires reference assemblies that are not installed (e.g. .NET Framework). The most common solution is to make sure Mono is fully updated on your machine (https://mono-project.com/download/) and that you are running the .NET Framework build of OmniSharp (e.g. 'omnisharp.useModernNet': false in C# Extension for VS Code).
"Can I fix this?"
Yes, just set omnisharp.useModernNet
property to false.
Upvotes: 1