Visual Studio代码:更改默认终端后使用了错误的分隔符
Visual Studio Code: Wrong separator being used after changing default terminal
在 Visual Studio 代码中,我将默认终端更改为命令提示符。
当我想调试我的 Azure 函数时,执行以下命令:
Executing task: .venv\Scripts\activate ; func host start <
不过,我认为应该把命令分隔符“&&”而不是“;”。
否则func host start不会执行。
Executing task: .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”。
感谢您ejizba. Posting your suggestion作为帮助其他社区成员的回答。
“调试配置在 .vscode
文件夹中的 tasks.json
和 launch.json
文件中指定。'windows' 'command' 属性默认为 PowerShell分隔符 (;
),但欢迎您将其切换为 cmd 分隔符(我相信那只是 &&
)。
但是,因为我认为我们可以重构 tasks.json
,使其不使用特定于终端的分隔符并防止将来出现类似问题。"
更多信息请参考此
在 Visual Studio 代码中,我将默认终端更改为命令提示符。 当我想调试我的 Azure 函数时,执行以下命令:
Executing task: .venv\Scripts\activate ; func host start <
不过,我认为应该把命令分隔符“&&”而不是“;”。 否则func host start不会执行。
Executing task: .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”。
感谢您ejizba. Posting your suggestion作为帮助其他社区成员的回答。
“调试配置在 .vscode
文件夹中的 tasks.json
和 launch.json
文件中指定。'windows' 'command' 属性默认为 PowerShell分隔符 (;
),但欢迎您将其切换为 cmd 分隔符(我相信那只是 &&
)。
但是,因为我认为我们可以重构 tasks.json
,使其不使用特定于终端的分隔符并防止将来出现类似问题。"
更多信息请参考此