无法找到任何已安装的 .NET SDK

It was not possible to find any installed .NET SDKs

我已经安装了多个版本的 .NET Sdk.Now Omnisharp 建议无法正常工作。

输出显示这些

[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /BO-V2/Techne-Travel/travel-techne-bo-for-ota/src/Application/Application.csproj
A compatible installed .NET SDK for global.json version [6.0.101] from [/BO-V2/Techne-Travel/travel-techne-bo-for-ota/global.json] was not found.
Install the [6.0.101] .NET SDK or update [/BO-V2/Techne-Travel/travel-techne-bo-for-ota/global.json] with an installed .NET SDK:
  It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download
A compatible installed .NET SDK for global.json version [6.0.101] from [/BO-V2/Techne-Travel/travel-techne-bo-for-ota/global.json] was not found.
Install the [6.0.101] .NET SDK or update [/BO-V2/Techne-Travel/travel-techne-bo-for-ota/global.json] with an installed .NET SDK:
  It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download
[fail]: OmniSharp.MSBuild.ProjectLoader
        Unable to locate the .NET SDK. Check that it is installed and that the version specified in global.json (if any) matches the installed version.
[fail]: OmniSharp.MSBuild.ProjectLoader
        The SDK 'Microsoft.NET.SDK.WorkloadAutoImportPropsLocator' specified could not be found.
[fail]: OmniSharp.MSBuild.ProjectManager

但 dotnet --info 显示此输出


.NET SDK (reflecting any global.json):
 Version:   6.0.101
 Commit:    ef49f6213a

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  20.04
 OS Platform: Linux
 RID:         ubuntu.20.04-x64
 Base Path:   /usr/share/dotnet/sdk/6.0.101/

Host (useful for support):
  Version: 6.0.1
  Commit:  3a25a7f1cc

.NET SDKs installed:
  3.1.415 [/usr/share/dotnet/sdk]
  5.0.100 [/usr/share/dotnet/sdk]
  5.0.209 [/usr/share/dotnet/sdk]
  5.0.403 [/usr/share/dotnet/sdk]
  6.0.100 [/usr/share/dotnet/sdk]
  6.0.101 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.21 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.12 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.21 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.13 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

哪个 dotnet 命令

/usr/bin/dotnet

我在 google 中搜索并找到了这个 https://www.py4u.net/discuss/1941159.

下面我按照他们说的做了。 但我仍然面临同样的问题。 为什么这个问题?我该如何解决这个问题 setting.json

{
    "editor.formatOnSave": false,
    "editor.codeActionsOnSave": {
        "source.fixAll": false
    },
    "omnisharp.path": "latest",
}

omnisharp.json

{
    "MsBuild": {
        "UseLegacySdkResolver": true
    }
}

global.json

{
  "sdk": {
    "version": "6.0.101",
    "rollForward": "latestMinor"
  }
}

我应该怎么做才能使 omnisharp 正常工作? 没有 Omnisharp Suggestion,我无法继续工作。很难编码。请帮助我。

在此处查看文档 https://github.com/OmniSharp/omnisharp-vscode

Using .NET 6 builds of OmniSharp Starting with C# extension version 1.24.0, there is now an option to use build of OmniSharp that runs on the .NET 6 SDK. This build requires that the .NET 6 SDK be installed and does not use Visual Studio MSBuild tools or Mono. It only supports newer SDK-style projects that are buildable with dotnet build. Unity projects and other Full Framework projects are not supported.

To use the .NET 6 build, set omnisharp.useModernNet to true in your VS Code settings and restart OmniSharp.