已安装DotNet SDK,但无法识别-Linux Ubuntu/POPOS 22.04

gwbalxhn  于 2022-09-20  发布在  Linux
关注(0)|答案(2)|浏览(393)

昨天我让DotNet SDK工作得很好,今天当我登录到我的PC时,我更新了系统和VSCode,然后当我尝试运行dotnet watch run时,我收到了以下错误:


* You intended to execute a .NET application:

      The application 'watch' 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

以下是当我尝试执行SDK的APT安装时发生的情况(它显示已安装):

sudo apt install dotnet-sdk-6.0
[sudo] password for robinson: 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
dotnet-sdk-6.0 is already the newest version (6.0.400-1).
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

这是我的dotnet --info

global.json file:
  Not found

Host:
  Version:      6.0.8
  Architecture: x64
  Commit:       55fb7ef977

.NET SDKs installed:
  No SDKs were found.

.NET runtimes installed:
  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]

从我的谷歌来看,这似乎是路径问题,但我尝试添加了几个不同的路径,但仍然不起作用。以下是Which DotNet:

/usr/bin/dotnet

和我的回声路径:

/home/robinson/.nvm/versions/node/v18.7.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/robinson/.dotnet/tools

我是一个Linux新手,任何帮助都是感激的。我在一台x64计算机上运行POPO。

ca1c2owp

ca1c2owp1#

我也遇到了同样的问题,以下是我为解决这个问题所做的。

1.删除所有.NET包
sudo apt remove 'dotnet*'
sudo apt remove 'aspnetcore*'
1.通过删除repo.list文件,从APT删除了PMC存储库
sudo rm /etc/apt/sources.list.d/microsoft-prod.list
1.运行sudo apt update
1.通过sudo apt install dotnet-sdk-6.0安装.NET 6 SDK

这是DotNet/core的Github问题页面上提供的解决方案之一,如果上面的方法不适用于您,请遵循原始文章。https://github.com/dotnet/core/issues/7699

apeeds0o

apeeds0o2#

因此,我最终通过执行以下操作解决了这个问题:我卸载了所有与DotNet相关的内容:sudo apt remove 'dotnet*',然后执行了sudo apt autoremovesudo apt update

然后,我按照on this link的说明将二进制文件直接解压缩到/opt/文件夹中。一旦我向Path添加了必要的行(根据链接中的说明),一切都按预期进行。

然而,我建议首先遵循Saranga的说明,因为使用包管理器可能是更好的解决方案。谢谢大家。

相关问题