VS Code修改默认终端为CMD后调试Azure Function分隔符错误
我在Visual Studio Code中将默认终端修改为Command Prompt,调试Azure Function时会执行如下命令:
执行任务: .venv\Scripts\activate ; func host start <
但CMD的命令分隔符应为&&而非;,否则func host start命令无法正常执行,正确命令应为:
执行任务: .venv\Scripts\activate && func host start <
按常理该配置应自动识别,请问是否有方法手动修改该分隔符?
我的settings.json配置如下:
{ "terminal.integrated.automationShell.windows": "C:\\windows\\System32\\cmd.exe", "terminal.integrated.defaultProfile.windows": "Command Prompt", "terminal.integrated.profiles.windows": { "PowerShell": { "source": "PowerShell", "icon": "terminal-powershell" }, "Command Prompt": { "path": [ "${env:windir}\\Sysnative\\cmd.exe", "${env:windir}\\System32\\cmd.exe" ], "args": [], "icon": "terminal-cmd" }, "Git Bash": { "source": "Git Bash" }, "C:\\windows\\System32\\cmd.exe": { "path": "C:\\windows\\System32\\cmd.exe", "args": [], "icon": "terminal-cmd" }, "JavaScript Debug Terminal": { "extensionIdentifier": "ms-vscode.js-debug", "icon": "debug", "id": "extension.js-debug.debugTerminal", "title": "JavaScript Debug Terminal" } } }
解决方案
通过修改tasks.json即可自定义命令分隔符,配置示例如下:
{ "version": "2.0.0", "tasks": [ { "label": "cmd host start", "type": "shell", "dependsOn": "pip install (functions)", "windows": { "command": "${config:azureFunctions.pythonVenv}\\Scripts\\activate && func host start" }, "isBackground": true, "problemMatcher": "$func-python-watch", }, { "label": "pip install (functions)", "type": "shell", "osx": { "command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt" }, "windows": { "command": "${config:azureFunctions.pythonVenv}\\Scripts\\python -m pip install -r requirements.txt" }, "linux": { "command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt" }, "problemMatcher": [] } ] }
修改完成后,在launch.json中将preLaunchTask参数设置为cmd host start即可。
内容的提问来源于stack exchange,提问作者avaTMO
相关产品推荐
相关产品推荐

