微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

vs代码C#扩展的问题,部分项目由于OmniSharp加载有问题

如何解决vs代码C#扩展的问题,部分项目由于OmniSharp加载有问题

当我开始编辑 C# 文件时,我收到此警告消息

Some projects have trouble loading. Please review the output for more details.

我检查了输出,这就是我发现的

Starting OmniSharp server at 2/17/2021,6:06:51 AM
    Target: /Users/zeyad/Documents/SandBox/CSharpTut

OmniSharp server started with Mono 6.12.0.
    Path: /Users/zeyad/.vscode/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.7-beta.29/omnisharp/OmniSharp.exe
    PID: 1391

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on MacOS 10.13.6 (x64)
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.discovery.MSBuildLocator
        Located 2 MSBuild instance(s)
            1: Mono 16.6.0 - "/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/Current/bin"
            2: StandAlone 16.8.0 - "/Users/zeyad/.vscode/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.7-beta.29/omnisharp/.msbuild/Current/Bin"
[warn]: OmniSharp.CompositionHostBuilder
        It looks like you have Mono installed which contains a MSBuild lower than 16.8.0 which is the minimum supported by the configured .NET Core Sdk.
 Try updating Mono to the latest stable or preview version to enable better .NET Core Sdk support.
[info]: OmniSharp.MSBuild.discovery.MSBuildLocator
        Registered MSBuild instance: Mono 16.6.0 - "/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/Current/bin"
            CscToolExe = csc.exe
            CscToolPath = /Users/zeyad/.vscode/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.7-beta.29/omnisharp/.msbuild/Current/Bin/Roslyn
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpformattingWorkspaceOptionsprovider,Order: 0
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.Completion.Completionoptionsprovider,Order: 0
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsprovider,Order: 100
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsprovider,Order: 110
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsprovider,Order: 140
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in '/Users/zeyad/Documents/SandBox/CSharpTut'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
        No solution files found in '/Users/zeyad/Documents/SandBox/CSharpTut'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/Users/zeyad/Documents/SandBox/CSharpTut/Zeyad.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in '/Users/zeyad/Documents/SandBox/CSharpTut'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location '/Users/zeyad/Documents/SandBox/CSharpTut' on host 1365.
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /Users/zeyad/Documents/SandBox/CSharpTut/Zeyad.csproj
[fail]: OmniSharp.MSBuild.ProjectLoader
        This project targets .NET version that requires reference assemblies that do not ship with OmniSharp out of the Box (e.g. .NET Framework). The most common solution is to make sure Mono is installed on your machine (https://mono-project.com/download/) and that OmniSharp is started with that Mono installation (e.g. 'omnisharp.useGlobalMono':'always' in C# Extension for VS Code).
[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file '/Users/zeyad/Documents/SandBox/CSharpTut/Zeyad.csproj'.
/Users/zeyad/Documents/SandBox/CSharpTut/Zeyad.csproj
/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/Current/bin/Microsoft.Common.CurrentVersion.targets(1193,5): Error: This project targets .NET version that requires reference assemblies that do not ship with OmniSharp out of the Box (e.g. .NET Framework). The most common solution is to make sure Mono is installed on your machine (https://mono-project.com/download/) and that OmniSharp is started with that Mono installation (e.g. 'omnisharp.useGlobalMono':'always' in C# Extension for VS Code).

[fail]: OmniSharp.MSBuild.ProjectManager
        Attempted to update project that is not loaded: /Users/zeyad/Documents/SandBox/CSharpTut/Zeyad.csproj
[info]: OmniSharp.Roslyn.CSharp.Services.Diagnostics.CSharpDiagnosticWorkerWithAnalyzers
        Solution initialized -> queue all documents for code analysis. Initial document count: 0.

我检查了他们写的解决方solution is to make sure Mono is installed on your machine (https://mono-project.com/download/) and that OmniSharp is started with that Mono installation (e.g. 'omnisharp.useGlobalMono':'always' in C# Extension for VS Code).解决了问题,但第二天问题又出现了!

这是我在 settings.json 中添加内容

"omnisharp.path": "latest","omnisharp.useGlobalMono": "always"

我对 C# 的扩展是 C# 扩展和 Roslynator。

是否缺少为 C# 完全设置 Visual Studio 代码内容?我对 C# 完全陌生,我真的很感激任何帮助,以获得与 JavaScript 或 Golang 等其他编程语言相同的流畅感觉

注意:我使用的是 Mac,但这有什么区别吗?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。