Quantcast
Channel: Active questions tagged vs-code-settings - Stack Overflow
Viewing all articles
Browse latest Browse all 62

VSCode variable for multi-root workspace root directory

$
0
0

I'm using a VSCode multi-root workspace. I want to define some tasks in myprojects.code-workspace using a variable for the root directory.

In a regular .vscode/tasks.json I could use ${workspaceFolder}.

However when I create this simple task in .project.code-workspace:

{"label":   "foo","type":    "shell","command": "echo ${workspaceFolder}"}

...it prints the first workspace path:

/home/username/myprojects/project1

instead of:

/home/username/myprojects

So the ${workspaceFolder} variable is obviously unsuitable.

Is there a variable that refers to the multiroot workspace's root?


UPDATE

To address the "why do you want that" query. It's a very common developer setup: similar to a monorepo as all projects are open simultaneously (for convenience), but not really a monorepo:

myprojects/           # multi-root workspace's root  .code-workspace     # has tasks which target all projects (so needs multiroot's root directory)  project1/    .git/    src/  project2/    .git/    src/  project3/    .git/    src/

Viewing all articles
Browse latest Browse all 62

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>