What does “on folder open” mean in VSCode's “run on folder open” tasks?

别来无恙 提交于 2019-12-25 01:37:27

问题


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?

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.)


回答1:


"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. Open the command palette (SHIFT+CMD+P) and choose "Tasks: Manage Automatic Tasks in Folder"

  2. Choose "Allow Automatic Tasks in Folder"

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

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.

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



来源:https://stackoverflow.com/questions/58866184/what-does-on-folder-open-mean-in-vscodes-run-on-folder-open-tasks

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