What is the working directory of a Visual Studio Code task?
According to the official documentation, the default should be the workspace directory, i.e., workspaceFolder, but running a task which simply executes echo $PWD, it shows the parent directory of workspaceFolder.
In other words, given dir1/dir2/.vscode/tasks.json, the following trivial task prints dir1 while the workspaceFolder refers to dir2 (the actual workspace directory).
What should I do to run a task from the workspaceFolder? Changing the cwd option does not help.
tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "Sample",
"command": "echo PWD=$PWD workspaceFolder=${workspaceFolder}",
"options": {
"cwd": "${workspaceFolder}"
}
}
]
}
Execution output:
> Executing task: echo PWD=$PWD workspaceFolder=/home/ubuntu/dir1/dir2 <
PWD=/home/ubuntu/dir1 workspaceFolder=/home/ubuntu/dir1/dir2
As additional and probably relevant note, I am developing remotely using the Remote - SSH extension.