1

I am setting up a build process which incorporates bash scripts already defined as a first-step into using tasks.json in my builds. Scripts must be run in order and it is essential that they run in sequence and not parallel since subsequent scripts depend on the output of the previous ones.

Setting "dependsOrder": "sequence" is ensuring the scripts are run in order, but there is an overlap such that the second script is being called before the first script is called and so on; ie: they are still running in parallel.

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "label": "pageBuilder",
    "tasks": [
        {
            "label": "build",
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "dependsOrder": "sequence",
            "dependsOn": [
                "buildCorePages", "convertMarkdownToHtml", "buildArticles"
            ],
            "problemMatcher": "$gcc"
        },
        {
            "label": "convertMarkdownToHtml",
            "type": "shell",
            "command": "${workspaceRoot}\\build_scripts\\convertMarkdownToHtml.sh"
        },
        {
            "label": "buildCorePages",
            "type": "shell",
            "command": "${workspaceRoot}\\build_scripts\\buildCorePages.sh"
        },
        {
            "label": "buildArticles",
            "type": "shell",
            "command": "${workspaceRoot}\\build_scripts\\buildArticles.sh"
        }
    ]
}

How can I force a wait for script completion?

michaelekins
  • 529
  • 1
  • 7
  • 23
  • I would say that your dependent tasks may need to have problem matchers too. Even `"problemMatcher": []` might suffice. Easy to try. – Mark Feb 19 '21 at 16:36
  • Thanks for the suggestion, didn't work though - even with problemMatcher in every task they are running in parallel. Tried [] and also "$gcc" – michaelekins Feb 19 '21 at 18:05
  • You might look at this answer https://stackoverflow.com/a/54527723/836330 about how to make the `problemMatcher` entries that has worked for me (at least once ;>}) – Mark Feb 19 '21 at 18:21
  • The link indicates it's related to the terminal output, and my scripts are not outputting to the terminal (new terminal windows are launching and echo statements are showing up there instead). This could well be the problem - investigating this now thanks – michaelekins Feb 19 '21 at 20:31
  • 1
    As an update, I have been unable to get this to work and instead have created a wrapper script "buildAll.sh" which is referenced in my tasks.json and from which I can control the run order / ensure parallelism. This seems like a hack though and so keeping question open for a better answer. – michaelekins Feb 25 '21 at 21:12

0 Answers0