11

I want "tasks: Allow Automatic Tasks In Folder" to be enabled by default when i open a project

this is the tasks.json

{
"version": "2.0.0",
"tasks": [
    {
        "type": "npm",
        "script": "gulp",
        "runOptions": {
            "runOn": "folderOpen"
        }
    }
]

}

it runs on start but only if i call "tasks: Allow Automatic Tasks In Folder" via cmd+shift+p and reopen the project

i need this to be enabled by default. How can i do that ?

  • Does the `"runOn": "default"` option do what you want? – Mark Jun 17 '19 at 05:13
  • hey Mark thx for the reply :) unfortunately not .. with "runOn": "default" it wont fire on startup at all .. in this scenario i need to call "npm run gulp" manually in the vscode-terminal – Manuel Lehenberger Jun 25 '19 at 01:03
  • You may have to select the command "Tasks: Allow Automatic Tasks in Folder" in the command palette. And then I had to do a couple of restarts or reloads to get it to work the first time and then it seems better. With `"runOn": "folderOpen"`. – Mark Jun 25 '19 at 01:50
  • Sorry, I see that you were previously doing the command. I did have to do a couple of full restarts to get it to work. See https://stackoverflow.com/questions/56738821/is-it-possible-to-create-a-vs-code-extension-that-runs-a-specific-gulp-task/56745902#56745902 – Mark Jun 25 '19 at 02:07
  • 2
    In VSCode 1.40.0 you have to open the task palette and first select `Tasks: Manage Automatic Tasks in Folder` then you can select `Allow Automatic Tasks in Folder` – kumar303 Nov 11 '19 at 16:27
  • @kumar303 Your comment is an answer. I'll give you a chance to post it as answer otherwise I will in a couple days. – C Perkins Jan 30 '20 at 23:07
  • 1
    @c-perkins mine isn't an answer. What the OP is asking for is impossible. I only commented because there was a change in some version of VSCode that added an extra menu item before you can select what the OP described as the current workaround. Hopefully this helps someone who was confused (like me). – kumar303 Feb 01 '20 at 03:23
  • 2
    Actually once you set `Allow Automatic Tasks in Folder`, it works every time you open the folder. – aboutqx Jun 17 '20 at 01:50
  • 2
    This is a good question. But might need a rephrase: Where is the setting *Allow Automatic Tasks in Folder* stored and how can I activate it for all projects? – theking2 Feb 19 '21 at 08:37
  • @theking2 The [setting is now (July 2022) here](https://stackoverflow.com/a/72923640/6309) with VSCode 1.70. – VonC Jul 09 '22 at 18:10

2 Answers2

3

With VSCode 1.70 (July 2022) and issue 64618, there will also be a setting associated with the command "Allow Automatic Tasks in Folder".

See PR 154171 and commit 755d39f

There is now a task.allowAutomaticTasks to enable automatic tasks in the folder, with:

  • task.allowAutomaticTasks.on: Always
  • task.allowAutomaticTasks.auto: Prompt for permission for each folder
  • task.allowAutomaticTasks.off: Never

This is available today (July 2022) in the insider release.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

Until VSCode 1.70 (July 2022) it was not possible to Allow Automatic Tasks in Folder by default. It has to be set by the instructions of Manuel Lehenberger.

  1. In VScode type Ctrl+Shift+p
  2. Search and select Tasks: Manage Automatic Tasks in Folder
  3. Click Allow Automatic Tasks in Folder

This has to be done once only. (for every project folder). I make it my routine when creating a new project folder or workspace.

Btw the tasks - section can be incorperated in the .code-workspace file thus removing the need for a .vscode folder and tasks.json file and reducing the clutter.

EDIT: Outdated

theking2
  • 2,174
  • 1
  • 27
  • 36