使用 .Net6 Windows 10 在 Visual Studio OmniSharp 代码上出错

Getting Error on Visual Studio Code for OmniSharp with .Net6 Windows 10

您好,我通常使用 Visual Studio 创建项目,但建议尝试使用 VS Code 进行 .Net6 项目

我在编译器中遇到了一些错误

它以“C# 扩展某些项目加载有问题。请查看输出以获取更多详细信息”开头

这些是错误

Starting OmniSharp server at 10/01/2022, 19:56:35
    Target: d:\DevProjects\Reactivities\Reactivities.sln

OmniSharp server started.
    Path: c:\Users\Desktop\.vscode\extensions\ms-dotnettools.csharp-1.23.17\.omnisharp.37.17\OmniSharp.exe
    PID: 13868

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on Windows 6.2.9200.0 (x64)
[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 2 MSBuild instance(s)
            1: Visual Studio Community 2019 16.11.32002.261 16.11.2 - "C:\Program Files (x86)\Microsoft Visual Studio19\Community\MSBuild\Current\Bin"
            2: StandAlone 17.0.0 - "c:\Users\Desktop\.vscode\extensions\ms-dotnettools.csharp-1.23.17\.omnisharp.37.17\.msbuild\Current\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: Visual Studio Community 2019 16.11.32002.261 16.11.2 - "C:\Program Files (x86)\Microsoft Visual Studio19\Community\MSBuild\Current\Bin"
[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 'd:\DevProjects\Reactivities'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
        Detecting projects in 'd:\DevProjects\Reactivities\Reactivities.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'd:\DevProjects\Reactivities\API\API.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'd:\DevProjects\Reactivities\Application\Application.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'd:\DevProjects\Reactivities\Persistence\Persistence.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'd:\DevProjects\Reactivities\Domain\Domain.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in 'd:\DevProjects\Reactivities'.
[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 'd:\DevProjects\Reactivities' on host 11388.
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: d:\DevProjects\Reactivities\API\API.csproj
[warn]: OmniSharp.MSBuild.ProjectLoader
        Targeting .NET 6.0 in Visual Studio 2019 is not supported.
[info]: OmniSharp.MSBuild.ProjectManager
        Successfully loaded project file 'd:\DevProjects\Reactivities\API\API.csproj'.
d:\DevProjects\Reactivities\API\API.csproj
C:\Program Files\dotnet\sdk.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.targets(134,5): Error: Targeting .NET 6.0 in Visual Studio 2019 is not supported.

[info]: OmniSharp.MSBuild.ProjectManager
        Adding project 'd:\DevProjects\Reactivities\API\API.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: d:\DevProjects\Reactivities\Application\Application.csproj
[info]: OmniSharp.MSBuild.ProjectManager
        Successfully loaded project file 'd:\DevProjects\Reactivities\Application\Application.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project 'd:\DevProjects\Reactivities\Application\Application.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: d:\DevProjects\Reactivities\Persistence\Persistence.csproj
[info]: OmniSharp.MSBuild.ProjectManager
        Successfully loaded project file 'd:\DevProjects\Reactivities\Persistence\Persistence.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project 'd:\DevProjects\Reactivities\Persistence\Persistence.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: d:\DevProjects\Reactivities\Domain\Domain.csproj
[info]: OmniSharp.MSBuild.ProjectManager
        Successfully loaded project file 'd:\DevProjects\Reactivities\Domain\Domain.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project 'd:\DevProjects\Reactivities\Domain\Domain.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: API
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: Application
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: Persistence
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: Domain
Received response for /v2/getcodeactions but could not find request

我不确定为什么会这样,搜索后我发现有些人说 OmniSharp 与 .net6 不兼容

如果有人有任何解决方案,请帮助,谢谢。

尝试将 VS Code 和 Omnisharp 更新到最新版本。如果没有帮助 - 安装 VS 2022 并再次尝试 运行 VS Code。