vscode launch.json与tasks.json

区别

launch.json: 用于debug
tasks.json: 用于执行一切任务

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: 当前文件",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "justMyCode": true,
            "args": ["--mg"]
        }
    ]
}

必要key:

  • version
  • configurations
    • name: launch的名字,随便起
    • “program”: “${file}”, 表示当前文件
    • “justMyCode”: true, 调试时只跳转到自己的代码
    • args 命令行参数

F5或者侧边栏的Debug中选择要运行的lauch
vscode launch.json与tasks.json_第1张图片

tasks.json

例如我们要用cmake编译运行

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "my cmake build",
            "type": "shell",
            "command": "cmake -B build ; cmake --build build --config=Release",
            "problemMatcher": [
                "$msCompile"
            ]
        }
    ]
   }

其中 problemMatcher是指扫描错误并将错误录入到右侧的报错窗口中

使用control+shift+p然后tasks: run task来运行task

你可能感兴趣的:(vscode,json,ide)