VSCODE任务脚本TS5042构建:选项'项目'不能与命令行上的源文件混合使用

时间:2016-11-05 09:35:11

标签: typescript compilation task visual-studio-code

我正在使用vscode运行tasks.json中定义的任务来编译文件夹中的typescripts文件。但我不断收到错误“Typescript TS5042 Build:Option'项目'不能与命令行上的源文件混合”。

当我从命令行(powershell)运行此命令时,它工作正常!

我的tasks.json

{
    "version": "0.1.0",
    "command": "tsc",
    "isShellCommand": true,
    "args": [],
    "tasks": [
        {
            "taskName": "CompileApp",
            "args": [
                "--p", "app/"
            ],
            "isBuildCommand": true,
            "problemMatcher": "$tsc"
        }
    ]
}

1 个答案:

答案 0 :(得分:2)

您需要将以下选项添加到任务部分" suppressTaskName"。在你的情况下,它看起来像这样:

code
{
    "version": "0.1.0",
    "command": "tsc",
    "isShellCommand": true,
    "args": [],
    "tasks": [
        {
            "taskName": "CompileApp",
            "args": [
                "--p", "app/"
            ],
            "isBuildCommand": true,
            "problemMatcher": "$tsc",
            "suppressTaskName": true
        }
    ]
}