Configuring a dependent task in vscode

I have the nrfConnect task that builds my project in vscode.

I need to add a script to execute before the nrfConnect task.

I added a task to my tasks.json but the task that I need to execute before the nrfConnect build, does not execute;;

I even replaced the script with a simple echo command and it still does not execute - I do not see the string "I AM A SUBTASK" in the terminal output

My tasks.json script below

What am I missing?

Thanks

Andy

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "subtask1",
            "type": "shell",
            "command": "echo I AM A SUBTASK"
        },
        {
            "type": "nrf-connect-build",
            "config": "${workspaceFolder}/build",
            "runCmake": false,
            "problemMatcher": [
                "$gcc",
                "$cmake",
                "$kconfig",
                "$kconfig_syntax",
                "$kconfig_syntax_files",
                "$dts",
                "$dts_syntax"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "label": "nRF Connect: Build myproject/build (active-debug)",
            "dependsOn": [
                "subtask1"
            ],

        }
    ]
}

  • I can execute my "subtask1" task by selecting "terminal->run build task" but not together with the nrf-connect build task

    I set the default task to be subtask1" .But when I select " build" or "pristine build" vscode still bypasses "subtask1" and executes the nrf-connect" build task. How can I make them run one after another - first "subtask1" THEN "nrf-connect-build" task??
    Everything is so complicated in vscode even the simplest things. Very frustrating

  • Hi,

    I have made my own test on this and I can see "I AM A SUBTASK" in the VS Code Terminal.
    You need to add the following line <"dependsOrder": "sequence",>. You can put this line just before "dependsOn" line.

    Best regards,
    Dejan

  • Adding dependsOrder did not help my issue. What I want to happen is when I click "build" or "pristine build"  the "subtask1" executes first and the nRF connect task. How can that be accomplished?

  • Hi,

    This is how I did it. I built asset_tracker_v2 example. One small difference from your tasks.json is that I have entered the full path to the build folder in the "config" section.

    {
        "version": "2.0.0",
        "tasks": [
            {
                "label": "subtask1",
                "type": "shell",
                "command": "echo I AM A SUBTASK"
            },
            {
                "type": "nrf-connect-build",
                "config": "c:\\path_to_the_project\\asset_tracker_v2\\build",
                "runCmake": false,
                "problemMatcher": [
                    "$gcc",
                    "$cmake",
                    "$kconfig",
                    "$kconfig_syntax",
                    "$kconfig_syntax_files",
                    "$dts",
                    "$dts_syntax"
                ],
                "group": "build",
                "label": "nRF Connect: Build asset_tracker_v2/build (active)",
                "dependsOrder": "sequence",
                "dependsOn": [
                    "subtask1"
                ],
            }
        ]
    }
    
    


    Best regards,
    Dejan

  • I tried using full path. My tasks.json looks exactly like yours but when I click build or pristine build the subtask does not execute.

    How do you invoke your build? 

    Are you on Mac or Windows?

    Thanks

Related