如何使用 vscode 集成终端在另一个终端中 运行 任务
How to run task in another terminal with vscode integrated terminal
ITNOA
嗨,
我的问题是 vscode 中的默认集成终端与需要的 tasks.json 不同。
所以当我想在 tasks.json 中执行 运行 命令时,我遇到了很多麻烦。
例如,如果您在 tasks.json 中将默认集成终端设置为 wsl, and you want to run bat file,如下所示,您会遇到一些错误并且任务无法正常工作。
"tasks": [
{
"label": "build",
"type": "shell",
"command": "build.bat",
"args": [],
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "shared",
"showReuseMessage": true,
"clear": false
}
}
]
正如您在 vscode documents for tasks, one section is about common questions 中看到的那样
Can a task use a different shell than the one specified for the Integrated Terminal?
并根据以下详细信息回答此问题
You can override a task's shell with the options.shell property. You can set this per task, globally, or per platform. For example, to use cmd.exe on Windows, your tasks.json would include:
{
"version": "2.0.0",
"windows": {
"options": {
"shell": {
"executable": "cmd.exe",
"args": [
"/d", "/c"
]
}
}
},
...
ITNOA
嗨,
我的问题是 vscode 中的默认集成终端与需要的 tasks.json 不同。
所以当我想在 tasks.json 中执行 运行 命令时,我遇到了很多麻烦。
例如,如果您在 tasks.json 中将默认集成终端设置为 wsl, and you want to run bat file,如下所示,您会遇到一些错误并且任务无法正常工作。
"tasks": [
{
"label": "build",
"type": "shell",
"command": "build.bat",
"args": [],
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "shared",
"showReuseMessage": true,
"clear": false
}
}
]
正如您在 vscode documents for tasks, one section is about common questions 中看到的那样
Can a task use a different shell than the one specified for the Integrated Terminal?
并根据以下详细信息回答此问题
You can override a task's shell with the options.shell property. You can set this per task, globally, or per platform. For example, to use cmd.exe on Windows, your tasks.json would include:
{
"version": "2.0.0",
"windows": {
"options": {
"shell": {
"executable": "cmd.exe",
"args": [
"/d", "/c"
]
}
}
},
...