VSCode 未在文件夹打开时运行任务

Mar*_*arc 3 visual-studio-code vscode-tasks

我正在使用 TypeScript,并且经常不得不tsc-watch手动启动任务。根据博客 VSCode v1.30+ 可以在打开文件夹时自动运行任务,但这对我不起作用(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"
            }
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

顺便说一句:也试过这个扩展,它也没有启动任务。

Sko*_*pEN 5

这项工作在 VSCode v. 1.42.1 my 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
            }
        }
    ]
   }
Run Code Online (Sandbox Code Playgroud)

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