.net dotnet run在Ubuntu 22.04中找不到已安装的运行时

e4eetjau  于 2023-01-14  发布在  .NET
关注(0)|答案(1)|浏览(356)

我试图运行. net 6程序,但它是抱怨框架丢失.
sdk已安装,如您所见:

rami@rami-ThinkPad:~$ dotnet --list-sdks
3.1.426 [/usr/share/dotnet/sdk]
6.0.405 [/usr/share/dotnet/sdk]
7.0.102 [/usr/share/dotnet/sdk]

但是当我试着运行一个程序时,我得到了这个:

dotnet run
Building...
You must install or update .NET to run this application.

App: /home/rami/th-work/internal-mkj-api/Internal-MKJ-API/bin/Debug/net6.0/Internal-MKJ-API
Architecture: x64
Framework: 'Microsoft.NETCore.App', version '6.0.0' (x64)
.NET location: /usr/share/dotnet

The following frameworks were found:
  3.1.32 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  7.0.2 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Learn about framework resolution:
https://aka.ms/dotnet/app-launch-failed

To install missing framework, download:
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=6.0.0&arch=x64&rid=ubuntu.22.04-x64

这是在我运行Ubuntu的自动更新并重新启动计算机后开始的。

qvtsj1bj

qvtsj1bj1#

我能够解决这个问题的帮助下tip @omajid给出的意见。dotnet --info显示的sdk安装,但没有运行时。可能这个问题是由事实造成的,我安装了不同的dotnet版本使用不同的来源,从Ubuntu Repo和Windows中删除了所有内容,只使用Ubuntu Repo重新安装,解决了这个问题。有关说明,请参阅this answer
我运行的命令:
删除所有内容:

sudo apt remove dotnet*
sudo apt remove aspnetcore*
sudo apt remove netstandard*

删除Microsoft存储库并安装dotnet-sdk-6:

sudo rm /etc/apt/sources.list.d/microsoft-prod.list
sudo apt update
sudo apt install dotnet-sdk-6.0

相关问题