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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM