You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows下VS Code使用外部终端调试.NET Azure Functions项目的配置问题

Windows下VS Code外部终端调试.NET Azure Functions 配置方案

attach模式是附加到已经运行的Function Host进程,进程的终端在启动时就已经确定,因此在attach配置里加console: externalTerminal不会生效,必须改用launch模式在进程启动时指定终端类型。

1. 完整launch.json配置

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch .NET Functions (External Terminal)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            // 可执行PowerShell命令 (Get-Command func).Source 查看本地func路径,将后缀exe替换为dll即可
            "program": "${env:APPDATA}\\npm\\node_modules\\azure-functions-core-tools\\bin\\func.dll",
            "args": ["host", "start"],
            "cwd": "${workspaceFolder}",
            "console": "externalTerminal",
            "justMyCode": false,
            "stopAtEntry": false,
            "internalConsoleOptions": "neverOpen"
        }
    ]
}

路径适配说明

  • 若通过Chocolatey安装Azure Functions Core Tools,program路径替换为C:\\ProgramData\\chocolatey\\lib\\azure-functions-core-tools\\tools\\func.dll
  • 若通过其他渠道安装,可在PowerShell执行(Get-Command func).Source获取func.exe路径,将后缀改为dll即可使用

2. 配套tasks.json配置

需确保工作区.vscode目录下的tasks.json存在对应build任务,示例配置如下:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "command": "dotnet",
            "type": "process",
            "args": [
                "build",
                "${workspaceFolder}/${workspaceFolderBasename}.csproj",
                "/property:GenerateFullPaths=true",
                "/consoleloggerparameters:NoSummary"
            ],
            "problemMatcher": "$msCompile"
        }
    ]
}

3. 验证步骤

  • 执行func --version确认Azure Functions Core Tools安装正常
  • 确认local.settings.json配置无错误,项目可正常编译
  • 按F5启动调试,会自动弹出外部终端运行Function Host,代码断点可正常命中

内容的提问来源于stack exchange,提问作者baouss

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.29 04:54:03