VS Code User tasks.json
Asked Answered
S

2

10

I've got a handful of custom tasks in VS Code that I want to share across multiple projects. The tasks are currently installed in $PROJECT_DIR/.vscode/tasks.json.

Where should I put my tasks file so that it is loaded by VS Code for all projects (I'm thinking something similar to User vs Workspace settings)?

I've tried ~/.vscode/tasks.json (I'm not sure if this is a location that VS Code uses or if it's something I created ages ago) and also $HOME/Library/Application \Support/Code/User/tasks.json (this is where custom settings.json and keybindings.json etc. are stored). Neither of these locations works.

At the moment, it seems like I can only have custom tasks defined in each workspace rather than globally. I couldn't see anything in the official documentation. Any pointers welcome?

Summerlin answered 17/10, 2018 at 11:39 Comment(0)
M
7

To answer the specific question about the location of the "user tasks" tasks.json file:

  • In Ubuntu, it's in ~/.config/Code/User/tasks.json
  • In Windows WSL, it's in /mnt/c/Users/<username>/AppData/Roaming/Code/User/tasks.json

[feel free to edit if you know the location in Mac or other systems]

Malvaceous answered 5/12, 2020 at 13:5 Comment(0)
L
3

This question is a duplicate of Create tasks in Visual Studio Code per user but I cannot mark it as such as that has not been upvoted or accepted yet. Reproduced here:


It looks like this will be in v1.42, the January 2020 release. See https://github.com/microsoft/vscode/issues/89343 (user level tasks). And https://github.com/microsoft/vscode/issues/1435.

In addition to having tasks in your .code-workspace file and in tasks.json in your open folder, you can now have tasks in a user level tasks.json next to your user settings.json.

Open a folder that has some tasks. The vscode project is a good example.

Run the Open User Tasks command to create a tasks.json file next to your user settings.json file.

Add a shell or process type task to the new tasks.json. Only those two types of task are supported here.

Run the Run Task command and verify that you see your new user level task. Verify that you can tell that it's a user level task in the task quick pick. Verify that you can configure your user level task by clicking the gear next to it in the quick pick. Verify that you can run the user task.

It is in the Insiders' Build already so presumably v1.42.

------- From the 1.42 release notes:

User level tasks

Tasks declared in tasks.json are now supported at the User Settings level. If you have a build script that you use across many projects, or if you don't want your tasks in a project folder, you can add your tasks in the user tasks.json file. You can run the Tasks: Open User Tasks command to create user level tasks. These tasks will be available across all folders and workspaces. Only the shell and process task types are supported here.

Levis answered 1/2, 2020 at 4:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.