【问题标题】:VSCode not running task on folder openVSCode未在文件夹打开时运行任务
【发布时间】:2019-04-30 14:35:58
【问题描述】:

我正在使用 TypeScript,并且经常不得不手动启动 tsc-watch 任务。根据博客 VSCode v1.30+ 可以automatically run tasks when a folder is opened 但这对我不起作用(v1.33.1) - 我打开我的文件夹并且没有任务正在运行。

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "type": "typescript",
            "tsconfig": "tsconfig.json",
            "isBackground": true,
            "problemMatcher": [
                "$tsc"
            ]
        },
        {
            "type": "typescript",
            "label": "TypeScript Compiler Watcher Thingy...",
            "tsconfig": "tsconfig.json",
            "option": "watch",
            "problemMatcher": [
                "$tsc-watch"
            ],
            "runOptions": {
                "runOn": "folderOpen"
            }
        }
    ]
}

顺便说一句:也试过this extension,它也没有启动任务。

【问题讨论】:

  • 当您第一次使用该任务配置打开任务时,它会提示您授予自动运行任务的权限。您可能不小心点击了“否”。尝试运行命令“允许文件夹中的自动任务”
  • 我对“tsc watch”2019.11也有同样的问题
  • 有没有人找到可行的解决方案???
  • Ctrl+SHIFT+PTasks: Manage Automatic Tasks in Folder 并选择 Allow Automatic Tasks in folder 并重新启动 VS Code

标签: visual-studio-code vscode-tasks


【解决方案1】:

这项工作在 VSCode v. 1.42.1 我的 tasks.json 中

    {
     "version": "2.0.0",
     "tasks": [
        {
            "type": "typescript",
            "tsconfig": "tsconfig.json",
            "label": "TypeScript Compiler Watching...",
            "option": "watch",
            "presentation": {
                "echo": true,
                "reveal": "silent",
                "focus": false,
                "panel": "shared"
            },
            "isBackground": true,
            "runOptions": {"runOn": "folderOpen"},
            "problemMatcher": [
                "$tsc-watch"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
   }

如果这仍然无法在项目文件夹中打开,请尝试 Ctrl+shift+P 和 Tasks: Manage Automatic Tasks in Folder,然后在主项目文件夹或正在运行的文件夹中选择“允许文件夹中的自动任务”。

【讨论】:

    猜你喜欢
    • 2023-04-04
    • 1970-01-01
    • 2022-11-23
    • 1970-01-01
    • 2020-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-11
    相关资源
    最近更新 更多