azure-dev
azure-dev copied to clipboard
[vscode] "dotenv" tasks cannot "end" with nested background tasks
Using "background" tasks in "dotenv" does not result in "control" being returned. The result is that attempting to set a preLaunchTask in launch.json will never result in the debugger launching.
In the below example of Start Web the Web npm start task will never end because npm run start runs continuously in the background. If Web npm start is configured as a background task with a problemMatcher it will still not return control to the parent Start Web task when it reaches an acceptable state.
{
"label": "Start Web",
"type": "dotenv",
"targetTasks": [
"Restore Web",
"Web npm start"
],
"file": "${input:dotEnvFilePath}",
"dependsOn": [
"Setup Web Env"
],
},

Example configuration for Web npm start that would work in isolation (except for the lack of dotenv)... note the "isBackground" and "problemMatcher" configurations:
{
"label": "Web npm start",
"detail": "Helper task--use 'Start Web' task to ensure environment is set up correctly",
"type": "shell",
"command": "npm run start",
"options": {
"cwd": "${workspaceFolder}/src/web/",
"env": {
"BROWSER": "none"
}
},
"presentation": {
"panel": "dedicated",
},
"isBackground": true,
"problemMatcher": [
"$ts-webpack-watch"
]
},
When this configuration is used the Web npm start task reaches a "terminal" state but the "Start Web" task stays in a pending state:
