VScode “omnisharp.useGlobalMono”报错问题

最近在更新了Unity后,vscode右下角总是会弹出:

“Some projects have trouble loading. Please review the output for more detail"

我尝试重新安装dotnet、dotnet@6无果。
重装Mono无果。

最后在下面找到了解决方法。

https://github.com/OmniSharp/omnisharp-vscode/issues/5228

我的报错信息大致如下:

Starting OmniSharp server at 2022/5/25 21:24:06
    Target: /home/mk/workLiu/simulation/unity/L_Learn

OmniSharp server started with .NET 6.0.300
.
    Path: /home/mk/.vscode/extensions/ms-dotnettools.csharp-1.25.0-linux-x64/.omnisharp/1.39.0-net6.0/OmniSharp.dll
    PID: 26112

[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 3 MSBuild instance(s)
            1: .NET Core SDK 6.0.300 17.2.0 - "/home/mk/.dotnet/sdk/6.0.300/"
            2: .NET Core SDK 6.0.202 17.1.1 - "/home/mk/.dotnet/sdk/6.0.202/"
            3: .NET Core SDK 6.0.104 17.0.0 - "/home/mk/.dotnet/sdk/6.0.104/"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: .NET Core SDK 6.0.300 17.2.0 - "/home/mk/.dotnet/sdk/6.0.300/"
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.MSBuild.ProjectSystem
        Detecting projects in '/home/mk/workLiu/simulation/unity/L_Learn/L_Learn.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/home/mk/workLiu/simulation/unity/L_Learn/Assembly-CSharp.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/home/mk/workLiu/simulation/unity/L_Learn/Assembly-CSharp-Editor.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in '/home/mk/workLiu/simulation/unity/L_Learn'.
[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 '/home/mk/workLiu/simulation/unity/L_Learn' on host 25934.
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /home/mk/workLiu/simulation/unity/L_Learn/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 '/home/mk/workLiu/simulation/unity/L_Learn/Assembly-CSharp.csproj'.
/home/mk/workLiu/simulation/unity/L_Learn/Assembly-CSharp.csproj
/home/mk/.dotnet/sdk/6.0.300/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).

[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /home/mk/workLiu/simulation/unity/L_Learn/Assembly-CSharp-Editor.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 '/home/mk/workLiu/simulation/unity/L_Learn/Assembly-CSharp-Editor.csproj'.
/home/mk/workLiu/simulation/unity/L_Learn/Assembly-CSharp-Editor.csproj
/home/mk/.dotnet/sdk/6.0.300/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: /home/mk/workLiu/simulation/unity/L_Learn/Assembly-CSharp.csproj
[fail]: OmniSharp.MSBuild.ProjectManager
        Attempted to update project that is not loaded: /home/mk/workLiu/simulation/unity/L_Learn/Assembly-CSharp-Editor.csproj
[warn]: OmniSharp.Roslyn.CSharp.Services.InlayHints.InlayHintService
        Inlay hints requested for document not in workspace Location { FileName = /home/mk/workLiu/simulation/unity/L_Learn/Assets/Scripts/ExperimentB/RelationFeedbackGroupController.cs, Range = Range { Start = Point { Line = 0, Column = 0 }, End = Point { Line = 113, Column = 9 } } }

解决方法:

VScode “omnisharp.useGlobalMono”报错问题

I'm having a similar problem and log. It started two days ago out of the blue.

Edit: Search omnisharp.useModernNet in your VS code settings and uncheck the box.

Omnisharp recently released a breaking change that flips the default state of this boolean. See the announcement here.

Vscode搜索omnisharp.useModernNet,取消勾选框即可。

评论区 0