I have a Visual Studio 2019 project which I want to compile and debug (or rather launch the MSBuild compiler as a launch task from within VS Code) with Visual Studio Code instead. This does work partially for me with the following configuration files:
launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "(Windows) Launch",
"type": "cppvsdbg",
"request": "launch",
"program": "x64/Debug/foo.exe",
"args": [],
"stopAtEntry": true,
"cwd": "E:/path/to/project/solution",
"environment": [],
"console": "externalTerminal",
"prelaunchTask": "msbuild"
}
]
}
tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "msbuild",
"type": "shell",
"command": "msbuild",
"isBackground": false,
"args": [
// Ask msbuild to generate full paths for file names.
"/property:GenerateFullPaths=true",
"/property:Configuration=Debug",
"/property:Platform=x64",
"/t:build"
],
"group": "build",
"presentation": {
// Reveal the output only if unrecognized errors occur.
//"reveal": "silent"
"revealProblems": "always",
"reveal": "always"
},
// Use the standard MS compiler pattern to detect errors, warnings and infos
"problemMatcher": "$msCompile"
}
]
}
For some reason, the launch task doesn't wait for the pre-launch task.
However, if I first run the msbuild task manually (it compiles as expected) and then run the debugging task with "prelaunchTask": "msbuild" commented-out, the debugger works as expected (i.e. I can step through the code, use breakpoints, etc. ).
Side note: On the internet, I saw people having the exact opposite problem: they were doing web development and had the problem that the pre-launch task and the build task were waiting on each other. This is why I have set "isBackground": false.
