无法在 VS Code 中调试 azure 函数,运行 func host start 时出错,但可以从 powershell 手动运行“func host start”

wil*_*yth 1 visual-studio-code azure-functions

我在 VS Code 中调试 Azure Functions 项目时遇到困难。我使用 func init 创建了一个天蓝色项目。当我从运行菜单中单击“调试”时,项目会生成,但在尝试运行“func host start”时,会出现以下错误:

> Executing task: func host start <

-Command : The term '-Command' is not recognized as the name of a cmdlet, function, script file, or opera
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ -Command func host start
+ ~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (-Command:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Run Code Online (Sandbox Code Playgroud)

如果我从 powershell 手动运行 func host start ,它工作正常。

到目前为止我已经尝试过:

  • 更新功能核心工具。
  • 更新.net
  • 卸载并重新安装 VS Code
  • 确保核心工具的路径位于路径环境变量中
  • 以管理员身份运行 vs code

希望能得到任何帮助来解决这个问题。

更新,添加错误截图: 在此输入图像描述

wil*_*yth 5

很多谷歌搜索发现了更改 VS Code 中默认终端的建议。它被设置为 powershell,但将其更改为命令提示符解决了该问题。

在此输入图像描述

通过输入“终端:选择默认配置文件”可以在命令托盘中找到设置。这将显示可用终端、命令提示符、gitbash、windows powershell、.net powershell 的列表。

选择命令提示符可以进行调试。

感谢大家的帮助!