Visual Studio Code 无法从带有“which dotnet”的路径中找到 dotnet

问题描述 投票:0回答:1

我已经在 MacBook 和我的终端中安装了 dotnet sdk

dotnet --info
返回有效信息。

但是在

Visual Studio Code
内部,当我尝试运行该项目时,我收到以下错误消息:

Failed to find dotnet from path with "which dotnet".
Cannot find .NET SDK installation from PATH environment. C# DevKit extension would not work without a proper installation of the .NET SDK accessible through PATH environment. Rebooting might be necessary in some cases. Check the PATH environment logged in the C# DevKit logging window. In some cases, it could be affected how VS code was started.
PATH=/usr/bin:/bin:/usr/sbin:/sbin

如何修复此错误?请注意,vscode 尝试从

PATH
读取
/bin/sh
,而不是
/bin/bash

c# .net visual-studio-code
1个回答
0
投票

确认 .NET SDK 的路径包含在您的 PATH 中。或者在你的 VSCode settings.json 上你可以设置它:

"terminal.integrated.env.osx": {
   "PATH": "/usr/local/share/dotnet:/usr/bin:/bin:/usr/sbin:/sbin"
 }

替代方案是将 bash 更改为 zsh 或默认 shell,

"terminal.integrated.defaultProfile.osx": "zsh"   // Or "bash" if you use Bash
© www.soinside.com 2019 - 2024. All rights reserved.