“在文件夹上打开"是什么? VSCode的“在文件夹打开时运行"的意思是任务? [英] What does "on folder open" mean in VSCode's "run on folder open" tasks?

查看:302
本文介绍了“在文件夹上打开"是什么? VSCode的“在文件夹打开时运行"的意思是任务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

VSCode去年添加了一项功能,该功能将自动运行任务在文件夹上打开" .但是,使用工作区时,在文件夹上打开"是什么意思?

VSCode added a feature last year that will auto-run a task "on folder open". But what does "on folder open" mean when using workspaces?

特别是,如果您打开工作区,"runOn": "folderOpen"任务会运行吗?如果是这样,怎么办?

Specifically, if you open a workspace, will "runOn": "folderOpen" tasks run? If so, how?

我之所以问是因为我将任务配置为自动运行,但是当我打开工作区时它没有运行. (手动触发任务后,任务可以正常运行.)

I'm asking because I configured a task to be auto-run, but it's not running when I open the workspace. (The task runs correctly when triggered manually.)

推荐答案

打开文件夹"任务 将在您打开工作区时运行,就像使用打开文件夹..."时一样. 打开非工作区文件夹时的链接.

"On folder open" tasks will run when you open a workspace, just like when you use the "Open Folder..." link when opening a non-workspace folder.

但是,还需要执行其他步骤:您需要选择自动运行任务.我通过文档中的细微提示指出了这一点:

However, there's an additional step required: you need to opt into auto-run tasks. I figured this out via subtle hint in the documentation which said this:

允许任务自动运行的每个人

everyone who allows tasks to be run automatically

这让我想知道如何使任务自动运行.事实证明,您需要进行配置更改,如下所示:

That made me wonder how to enable tasks to run automatically. It turns out there's a configuration change you need to make, as follows:

  1. 打开命令面板(SHIFT + CMD + P)并选择任务:管理文件夹中的自动任务"

  1. Open the command palette (SHIFT+CMD+P) and choose "Tasks: Manage Automatic Tasks in Folder"

选择允许文件夹中的自动任务"

Choose "Allow Automatic Tasks in Folder"

现在关闭并重新打开工作区,打开文件夹打开的任务将按预期运行.

Now close and re-open the workspace, and on-folder-open tasks will run as expected.

令人沮丧的是,此设置在通常的JSON设置文件中不存在,这意味着它不会出现在设置"搜索中.

Frustratingly, this setting is not present in the usual JSON settings files, which means that it won't show up in the search of Settings.

这使我浪费了大量时间来尝试查找此设置,这就是为什么我在此处发布一个问答对来帮助此问题的下一个受害者的原因.

This made me waste a bunch of time trying to find this setting, which is why I'm posting a Q&A pair here to help the next victim of this problem.

更新:我还建议VSCode将其添加到设置"中. https://github.com/microsoft/vscode/issues/64618#issuecomment- 554072124

UPDATE: I also suggested that VSCode add this to Settings. https://github.com/microsoft/vscode/issues/64618#issuecomment-554072124

这篇关于“在文件夹上打开"是什么? VSCode的“在文件夹打开时运行"的意思是任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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