每个用户在Visual Studio Code中创建任务 [英] Create tasks in Visual Studio Code per user

查看:216
本文介绍了每个用户在Visual Studio Code中创建任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我为 Visual Studio代码创建Node任务时,它创建了 tasks.json <您打开的文件夹的 .settings 文件夹中的/strong>文件(在这种情况下为node-app,如下图所示).即:它为每个文件夹创建一个任务.

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

我的问题是如何为每个用户创建一个任务,而不是基于项目的任务,以便我可以从任何文件夹执行节点代码,而不必为在Visual Studio Code中打开的每个文件夹创建相同的任务./p>

此外,如何在不打开文件夹的情况下执行单个文件.

解决方案

看起来将在2020年1月发行的v1.42中.请参见 https://github.com/microsoft/vscode/issues/89343 (用户级任务).和 https://github.com/microsoft/vscode/issues/1435 .

除了在.code-workspace文件和 您打开的文件夹中的task.json,现在可以在用户级别拥有任务 用户settings.json旁边的task.json.

打开一个包含一些任务的文件夹. vscode项目是一个不错的选择 例子.

运行打开用户任务"命令以在旁边创建一个task.json文件 您的用户settings.json文件.

将shell或进程类型任务添加到新的task.json.只有那两个 这里支持任务类型.

运行运行任务"命令并验证您是否看到新的用户级别 任务.验证您可以说出它是任务中的用户级任务 快速选择.验证您可以通过以下方式配置用户级别的任务 在快速选择中单击其旁边的齿轮.确认您可以 运行用户任务.

它已经在Insiders's Build中,大概是v1.42.

-------从 1.42发行说明:

用户级任务

tasks.json中声明的任务现在在用户设置中受支持 等级.如果您有一个跨多个项目使用的构建脚本, 或者,如果您不想将任务放在项目文件夹中,则可以添加 用户tasks.json文件中的任务.您可以运行任务:打开用户 任务命令来创建用户级任务.这些任务将是 在所有文件夹和工作空间中都可用.仅shell和 此处支持process任务类型.

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.

解决方案

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.

这篇关于每个用户在Visual Studio Code中创建任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆