tasks
tasks.json
用于管理编译任务。
主要定义 tasks
和 inputs
。一个示例 Python 项目的 tasks.json
如下:
{"version": "2.0.0","tasks": [{"label": "Current File","type": "shell","command": "/path/to/python","problemMatcher": [],"args": ["${file}","${input:arg1}","${input:arg2}"],"group": {"kind": "build","isDefault": false}"options": {"env": {"CUDA_VISIBLE_DEVICES": "0","PYTHONPATH": "${workspaceFolder}"}},}],"inputs": [{"id": "arg1","type": "pickString","description": "Choose an option","options": ["opt1","opt2"]},{"type": "promptString","id": "arg2","description": "Enter the value","default": "placeholder..."}]
}
启动任务的快捷键是 Shift + Cmd + B
可以使用 Task Manager 插件管理任务。
launch
launch.json
用于管理调试配置。一个示例 Python 项目的 launch.json
如下:
{"version": "0.2.0","configurations": [{"name": "Current File","type": "debugpy","request": "launch","program": "${file}","console": "integratedTerminal","justMyCode": true,"python": "/path/to/python","args": [],"env": {"CUDA_VISIBLE_DEVICES": "0","PYTHONPATH": "${workspaceFolder}"}}]
}
参考:vscode 自定义任务 | shumei52