unity3d Omnisharp未正确加载- Visual Studio代码和Unity

hfyxw5xn  于 2022-11-16  发布在  其他
关注(0)|答案(2)|浏览(782)

当我尝试在vscode中打开一个unity脚本时,我得到一个错误消息Some projects have trouble loading. Please review the output for more details.。当我选择Show 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 } } }

我不知道这是不是相关的,但是,统一的自动完成在vscode中也不工作。我可以输入代码,它在统一中工作,但我想有自动完成,并摆脱这个错误消息。我可以修复这个问题吗?谢谢。

bbmckpt7

bbmckpt71#

此项目面向需要未安装的引用程序集(例如.NET Framework)的.NET版本。最常见的解决方案是确保Mono在您的计算机上已完全更新(https://mono-project.com/download/),并且您正在运行OmniSharp的.NET Framework版本(例如“omnisharp. useModernNet”:在VS程式码的C#扩充中为false)。
“我能解决这个问题吗"
是,只需将omnisharp.useModernNet属性设置为false

btxsgosb

btxsgosb2#

正如控制台所说的问题(感谢你指示我检查omnisharp的控制台)是你没有omnisharp插件所期望的.NET版本。
我通过安装旧版本的扩展解决了这个问题,因为mu项目使用的是.NET 5,而更新版本的扩展正在搜索.NET 6。
我不确定你是否可以设置每个项目的.NET版本-可能,但没有找到一种方法。

相关问题