vscode tasks.json以及launch.json配置详解(待整理)

tasks.json

  taks.json文件一般用来设定build环境,通过Terminal > Configure Default Build Task呼出task.json文件,官网给出的例子如下:

  

{
  "version": "2.0.0",
  "tasks": [
    {
      "type": "shell",
      "label": "cl.exe build active file",
      "command": "cl.exe",
      "args": [
        "/Zi",
        "/EHsc",
        "/Fe:",
        "${fileDirname}\\${fileBasenameNoExtension}.exe",
        "${file}"
      ],
      "problemMatcher": ["$msCompile"],
      "group": {
        "kind": "build",
        "isDefault": true
      }
    }
  ]
}

  这里command用来指定要执行的程序,args字段用于记录执行command需要涉及到的参数。isDefault = true指定该tasks.json是(command + shift + b)快捷键执行的默认task。这里有更多详细的task.json的参数介绍。

 

lauch.json

  用来debug程序,快捷键为f5,通过Run > Add Configuration呼出lauch.json。官方给出的案例如下:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "cl.exe build and debug active file",
      "type": "cppvsdbg",
      "request": "launch",
      "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
      "args": [],
      "stopAtEntry": false,
      "cwd": "${workspaceFolder}",
      "environment": [],
      "externalConsole": false,
      "preLaunchTask": "cl.exe build active file"
    }
  ]
}

  program字段用来制定需要执行的程序。其余字段详见这里

  debug的例子还是看官方文档比较好,https://code.visualstudio.com/docs/cpp/config-msvc#_step-through-the-code

posted @ 2021-07-02 15:03  猪突猛进!!!  阅读(13157)  评论(0编辑  收藏  举报