我在 ubuntu 22.04 版本中使用 dotnet6。现在,当我运行 dotnet --version 时,出现以下错误。
jyothish@jyothish-Lenovo-G570:~$ dotnet --version
The command could not be loaded, possibly because:
* You intended to execute a .NET application:
The application '--version' does not exist.
* You intended to execute a .NET SDK command:
No .NET SDKs were found.
Download a .NET SDK:
https://aka.ms/dotnet-download
Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found
jyothish@jyothish-Lenovo-G570:~$
当我同时运行 dotnet --help 和 dotnet --list-runtimes 时,我得到了输出。
jyothish@jyothish-Lenovo-G570:~$ dotnet --list-runtimes
Microsoft.AspNetCore.App 6.0.8 [/usr/lib/dotnet/dotnet6-6.0.108/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.8 [/usr/lib/dotnet/dotnet6-6.0.108/shared/Microsoft.NETCore.App]
jyothish@jyothish-Lenovo-G570:~$ dotnet --help
Usage: dotnet [host-options] [path-to-application]
path-to-application:
The path to an application .dll file to execute.
host-options:
--additionalprobingpath <path> Path containing probing policy and assemblies to probe for.
--depsfile <path> Path to <application>.deps.json file.
--runtimeconfig <path> Path to <application>.runtimeconfig.json file.
--fx-version <version> Version of the installed Shared Framework to use to run the application.
--roll-forward <value> Roll forward to framework version (LatestPatch, Minor, LatestMinor, Major, LatestMajor, Disable)
--additional-deps <path> Path to additional deps.json file.
--list-runtimes Display the installed runtimes
--list-sdks Display the installed SDKs
Common Options:
-h|--help Displays this help.
--info Display .NET information.
jyothish@jyothish-Lenovo-G570:~
我该如何纠正这个问题并在 ubuntu 中恢复使用 dotnet6?
答案1
正如消息所示,您没有安装 SDK。我猜您只有运行时。请执行以下操作:
sudo apt install dotnet6
如果它告诉你有错误,请这样做
sudo apt -f install
如果这不起作用,请卸载所有 dotnet 软件包并重新安装 dotnet6