Search code examples
visual-studio-codevscode-tasks

How to run task in another terminal with vscode integrated terminal


My problem is default integrated terminal in vscode is different with tasks.json that needed.

so when I want to run command in tasks.json I having many trouble.

for example if you set default integrated terminal to wsl, and you want to run bat file in tasks.json like below, you got a some error and task does not working.

"tasks": [
    {
        "label": "build",
        "type": "shell",
        "command": "build.bat",
        "args": [],
        "presentation": {
            "echo": true,
            "reveal": "always",
            "focus": true,
            "panel": "shared",
            "showReuseMessage": true,
            "clear": false
        }
    }
]

Solution

  • As you can see in vscode documents for tasks, one section is about common questions that say something like below

    Can a task use a different shell than the one specified for the Integrated Terminal?

    and answer this question is yes with below details

    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"
                    ]
                }
            }
        },
        ...