首页 > 解决方案 > 在 VSCode 的集成终端中运行任务?

问题描述

当我过去运行任务(tasks.json)时,它们在 VSCode 的集成终端中运行。但是,在重置我的开发机器并重新安装所有内容后,我的任务现在在新的 cmd 窗口中运行。当任务因错误而失败时,这是一个问题。在这种情况下,cmd 窗口刚刚关闭,我无法读取实际错误是什么。

如何让任务再次在集成终端中运行?

标签: visual-studio-codetask

解决方案


ITNOA

如果您使用的是带有版本 2 的 task.json

你只需要像下面这样写presentation属性:tasks

        "presentation": {
            "echo": true,
            "reveal": "always",
            "focus": true,
            "panel": "shared",
            "showReuseMessage": true,
            "clear": false
        }

完整的例子如下

"tasks": [
    {
        "label": "example",
        "type": "shell",
        "command": "foo",
        "args": [],
        "presentation": {
            "echo": true,
            "reveal": "always",
            "focus": true,
            "panel": "shared",
            "showReuseMessage": true,
            "clear": false
        }
    }
]

有关更多信息,您可以阅读vscode task.json 帮助


推荐阅读