Create tasks in Visual Studio Code per user

感情迁移 提交于 2020-02-24 05:28:09

问题


When I created a Node task for Visual Studio Code it created a tasks.json file inside the .settings folder for the folder that you have open (node-app in this case as shown in the image below). ie: it creates a task per folder.

{
    "version": "0.1.0",
    "command": "node",
    "isShellCommand": true,
    "args": ["${file}"]
}

My question is how do you create a task per user rather than a project based task so that I can execute the node code from any folder rather that having to create the same task for each folder you open in Visual Studio Code.

Also how do you execute individual files without opening a folder.


回答1:


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.



来源:https://stackoverflow.com/questions/30949413/create-tasks-in-visual-studio-code-per-user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!