diff --git a/docs/debugtest/tasks.md b/docs/debugtest/tasks.md index 9474971a2d..ff553a8f8e 100644 --- a/docs/debugtest/tasks.md +++ b/docs/debugtest/tasks.md @@ -372,6 +372,29 @@ You can specify a task's run behaviors using the `runOptions` property: * **runOn**: Specifies when a task is run. * `default` - The task will only be run when executed through the **Run Task** command. * `folderOpen` - The task will be run when the containing folder is opened. The first time you open a folder that contains a task with `folderOpen`, you will be asked if you want to allow tasks to run automatically in that folder. You can change your decision later using the **Manage Automatic Tasks** command and selecting between **Allow Automatic Tasks** and **Disallow Automatic Tasks**. + +### Controlling automatic task execution + +The `task.allowAutomaticTasks` setting controls whether tasks with `"runOn": "folderOpen"` are allowed to run automatically when you open a workspace. This setting provides security by preventing unintended task execution. + +>**Note:** As of [VS Code 1.109](/updates/v1_109.md#automatic-tasks-disabled-by-default), the default for `task.allowAutomaticTasks` changed from `on` to `off` to improve security. + +* **off** (default) - Automatic tasks will not run when opening a workspace. You must explicitly allow them using the **Manage Automatic Tasks** command. +* **on** - Automatic tasks will always run when opening a workspace without prompting. +* **auto** - You will be prompted once per folder to allow or disallow automatic tasks. + +To change this setting, add it to your user or workspace settings: + +```json +{ + "task.allowAutomaticTasks": "off" +} +``` + +You can also manage automatic tasks on a per-workspace basis using the **Manage Automatic Tasks** command from the Command Palette, which allows you to choose **Allow Automatic Tasks** or **Disallow Automatic Tasks** for the current workspace. + +### Additional run options + * **instanceLimit** - The number of instances of the task that are allowed to run simultaneously. The default value is `1`. * **instancePolicy** - Determines what happens when a task has reached its `instanceLimit`. Can be set to: * `prompt` - Prompt the user which instance to terminate (default).