4

我最终试图设置 vscode 来构建打字稿,但我首先只是想运行一个简单的任务,我似乎无法让它工作。我现在只想从https://code.visualstudio.com/docs/editor/tasks运行“Hello world”任务,它只是将字符串回显到输出窗口。

我的 tasks.json 位于 .vscode 文件夹中,其内容为:

{
    "version": "0.1.0",
    "command": "echo",
    "isShellCommand": true,
    "args": ["Hello World"],
    "showOutput": "always"
}

当我尝试从命令面板运行任务并选择“任务:运行任务”时,当我希望看到此回显任务时,我看到“未找到任务”。我不知道为什么我在任务列表中看不到这个任务。

我究竟做错了什么?

未找到任务

FWIW,我的 vscode 版本是 1.11.1。

4

1 回答 1

-1

这适用于当前的 vscode:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "taskName": "MyHelloTask",
            "type": "shell",
            "command": "echo",
            "args": ["Hello\ World"],
            "presentation": {
                "echo": true,
                "reveal": "always",
                "panel": "shared"
            }
        }
    ]
}

什么问题?

The property showOutput is deprecated. Use the reveal
property inside the presentation property instead. 
See also the 1.14 release notes.

现在也isShellCommand变成了type,等等……

还要注意参数中的转义空格。(否则会引发对此的抱怨。是的,尽管它周围有引号。)

于 2017-09-13T08:13:28.690 回答