在我的 Mac m1 终端中找不到 dotnet 命令

dotnet command is not found in my Mac m1 terminal

我已经从官方网站下载了 .net5,但是 dotnet 命令无法被我的终端识别。

这是我经过一番研究后发现的-

  1. 我的 dotnet 文件夹存在于 /usr/local/share/dotnet

  2. 我用了这个命令,但没用sudo ln -s /usr/local/share/dotnet /usr/local/bin/dotnet

    1. 现在,每当我在终端中输入 dotnet 时,它都会显示 zsh: permission denied: dotnet
  3. 我也试过这个命令,但没用sudo ln -s /usr/local/share/dotnet /usr/bin/dotnet

    1. 现在,每当我在终端中输入 dotnet 时,它都会显示 zsh: command not found: dotnet
  4. 当我在 vscode 中打开我的 .cs 文件时,它显示错误 The .NET Core SDK cannot be located. .NET Core debugging will not be enabled. Make sure the .NET Core SDK is installed and is on the path.

这里有截图供参考

我该怎么办:(

安装 .NET 6 后出现相同(差不多)的问题破坏了我当前的 .NET 5 安装。

我通过以下方式修复了它:

1.删除当前 dotnet 安装的所有文件。

这是通过删除位于 /usr/local/share/

中的 dotnet 文件夹来完成的

(使用 Finders 'go to' 功能导航到那里,或者使用终端删除它)

2。重新安装 dotnet sdk

https://dotnet.microsoft.com

下载

3。将符号链接添加到当前的 dotnet 可执行文件。

sudo ln -s /usr/local/share/dotnet/x64/dotnet /usr/local/bin/

ℹ Note that the path to the dotnet executable is different from what you tried. Seems like a subfolder was added (/x64) at some point.