12

I have a build task that takes at least 2 seconds to finish in tasks.json.
I also have different very quick task for cleaning some files in tasks.json.

I have 3 configurations in launch.json: server, server_running_on_top_of_server and client.
All of them can be running separately, so all of them should have the build as a preLaunchTask.

So if I run those 3 configurations separately with build as preLaunchTask and cleaning specified in dependsOn of build, it's quite fine.

But when I want to run those 3 configurations together as a compound, it's not very intuitive.
I would like to first run build task and then server and after the server is up, then server_running_on_top_of_server and client.
The cleaning configuration should be run only for the client, but can be run everytime the build task is run.

"compounds": [
    {
        "name": "server, server_running_on_top_of_server and client",
        "configurations": ["server", "server_running_on_top_of_server", "client"]
    }

and

"tasks": [
    {
        "label": "build",
        "type": "shell",
        "command": "make",
        "args": [
            "-j4",
            "debug"
        ],
        "group": {
            "kind": "build",
            "isDefault": true
        },
        "dependsOn": "delete something",
        "presentation": {
            "panel": "shared"
        }
    },
    {
        "label": "delete something",
        "type": "shell",
        "command": "rm",
        "args": [
            "-f", "something"
        ],
        "presentation": {
            "panel": "shared"
        }
    },
    {
        "label": "wait 5 seconds",
        "type": "shell",
        "command": "sleep",
        "args": [
            "5"
        ]
    }
]

But the build task is run 3 times this way and also separately in 3 terminals even with presentation.panel: "shared" so it uses 12 cores instead of 4 so it totally lags my PC.
How to fix that?

And how to run the remaining 2 configurations after the server is up? Is there a better approach than to create another task that just waits some time?

Is there a possibility to specify more than 1 task in preLaunchTask? So I can assign build and cleaning task only for client.

Lukas Salich
  • 959
  • 2
  • 12
  • 30

0 Answers0