1. 打開vs工具命令提示
我的在文件夾C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts中:
選行x86或其他幾個都行,雙擊運行
2. 執行code打開vscode
3. 配置settings.json
{
"terminal.integrated.shell.windows": "C:/WINDOWS/System32/cmd.exe"
}
4. 配置launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "msvc launch",
"type": "cppvsdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"preLaunchTask": "msvc build"
}
]
}
5. 配置tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "msvc build",
"command": "cl.exe",
"args": [
"/Zi",
"/EHsc",
"/Fe:",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"${file}"
],
"problemMatcher": [
"$msCompile"
],
"group": "build"
}
]
}
6. 調試
直接在主函數文件中F5啓動調試。