vscode配置c/c++怎么让编译之后立刻运行?

只是想编译之后立刻运行,像sublime那样从文件读入后输出到下面控制台。
写了个tasks.json

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "0.1.0",
    "tasks": [
        {
            "taskName": "build",
            "command": "g++",
            "isShellCommand": true,
            "args": [
                "-o",
                "${workspaceRoot}/main",
                "${workspaceRoot}/main.cpp"
            ],
            "showOutput": "always"
        },
        {
            "taskName": "run",
            "command": "${workspaceRoot}/main",
            "isShellCommand": true,
            "showOutput": "always"
        }
    ]
}

为啥,第二个任务不会运行。。

阅读 6k
1 个回答

现在VS Code的任务是不会连续执行的。

解决方法:

  1. 利用外部工具,例如写脚本、msbuild、make等等

  2. 配置调试,不加断点,编译后再按F5运行

2017-03-02更新:

VS Code 1.10支持组合多个任务了,也可以给单个任务设快捷键。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题