Gertjan Brouwer
Gertjan Brouwer

Reputation: 1016

VSCode tasks dependsOn being run, task itself not

I have 2 tasks in my tasks.json. The first is CMAKE which runs correctly. The second is make which depends on the CMAKE being run first. When I use the option dependsOn cmake and run the task make, it only runs the cmake task but no the make task afterwards.

{
    "version": "2.0.0",
    "command": "sh",
    "args": [
        "-c"
    ],
    "presentation": {
        "echo": true,
        "reveal": "always",
        "focus": true,
        "panel": "new"
    },
    "tasks": [
        {
            "label": "cmake",
            "type": "shell",
            "options": {
                "cwd": "${workspaceRoot}/build"
            },
            "args": [
                "cmake -DCMAKE_BUILD_TYPE=Debug .."
            ]
        },
        {
            "label": "make",
            "type": "shell",
            "args": [
                "make -j8"
            ],
            "options": {
                "cwd": "${workspaceRoot}/build"
            },
            "dependsOn": [
                "cmake"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "problemMatcher": [
                "$gcc"
            ]
        }
    ]
}

Output of the executed make task:

Executing task: sh -c 'cmake -DCMAKE_BUILD_TYPE=Debug ..' <

-- Configuring done
-- Generating done
-- Build files have been written to: /home/gertjan/multiply/build

Press any key to close the terminal.

Upvotes: 1

Views: 1950

Answers (1)

Gertjan Brouwer
Gertjan Brouwer

Reputation: 1016

It apparently had something to do with the sh -c at the top of my task. I also changed the args to command in the tasks. My resulting tasks.json file:

{
    "version": "2.0.0",
    "presentation": {
        "echo": true,
        "reveal": "always",
        "focus": true,
        "panel": "new"
    },
    "tasks": [
        {
            "label": "cmake",
            "type": "shell",
            "command": "cmake -DCMAKE_BUILD_TYPE=Debug ..",
            "options": {
                "cwd": "${workspaceRoot}/build"
            }
        },
        {
            "label": "make",
            "type": "shell",
            "options": {
                "cwd": "${workspaceRoot}/build"
            },
            "command": "make -j8",
            "dependsOn": [
                "cmake"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

Upvotes: 1

Related Questions