I am trying to use environment variables within task in my tasks.json
file of a C# project in vscode
.
In my launch.json
file I have this code to parse a .env file:
"configurations": [
{
...
"envFile": "${workspaceFolder}/.env",
}
]
I then have in the tasks.json
file this task:
{
"label": "login",
"command": "sh",
"type": "shell",
"args": [
"${workspaceFolder}/etc/login.sh",
"${env:USERNAME}",
"${env:PASSWORD}"
]
}
This seems to be the code that's implied from https://code.visualstudio.com/docs/editor/tasks, however (from testing by echoing in another task) I have found these last two args
to be blank. After researching online I think I have found the reason, the configurations..env
is used by the tasks
themselves rather than being accessible by task.json
that run and so can't be accessed.
How do I create (use) these env variables
within the tasks.json
?