Kirill Metrik
Kirill Metrik

Reputation: 384

How to run several tasks in VSCode

I am trying to migrate to VSCode and having a problem with setting-up tasks. It is easy to define tasks in tasks.json but I would like to run several tasks simultaneously (which I can't).

Here is my use-case: I have two watchers in my project (one for gulp and another one for webpack). Plus I want to be able to run webpack task separately. When I run one of the watchers I cannot run anything else - VSCode requires me to terminate the running task at first.

In Visual Studio I used Task Runner where several tasks were running simultaneously. Is it possible to achieve the same in VSCode?

Upvotes: 7

Views: 988

Answers (2)

Parth
Parth

Reputation: 64

The problem is that "Run Test Task" and "Run Build Task" do not execute all tasks in that specific group. Usually you get a drop down selection so you can choose which task to execute. Since you have specified one of the tasks as default, the selection will be skipped and instead the default task is executed.

You can work around that by adding dependencies. Take the following example:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Echo 1",
            "command": "echo",
            "type": "shell",
            "args": [ "echo1" ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "dependsOn":["Echo 2"]
        },
        {
            "label": "Echo 2",
            "type": "shell",
            "command": "echo",
            "args": [ "echo2" ],
            "group": "build"
        }
    ]
}

Upvotes: 0

djolf
djolf

Reputation: 1196

Using compound tasks, you can specify dependsOn and dependsOrder on a separate task, and run them in parallel like this:

{
  "label": "start-tasks",
  "dependsOrder": "parallel",
  "dependsOn": [
      "taskOne",
      "taskTwo"
  ]
}

Upvotes: 4

Related Questions