Joaqo
Joaqo

Reputation: 51

How to specify multiple debugging commands in visual studio 2022 for c/c++?

In vs you can edit your debugging command in Configuration Properties -> Debugging. But when you have multiple debugging scenarios to review, it is very cumbersome to be constantly adjusting the Command Arguments entry.

I was hoping one can do similar to a cmake project in vscode, where you can edit a launch.json file that will have multiple debugging commands ready for you to select and run, each with their own arguments, for example:

{
    "name": "(Windows) Launch",
    "type": "cppvsdbg",
    "request": "launch",
    "program": "enter program name, for example ${workspaceFolder}/a.exe",
    "args": [],
    "stopAtEntry": false,
    "cwd": "${fileDirname}",
    "environment": [],
    "console": "externalTerminal"
},

Note: Answers to VS2019 are also welcomed.

Upvotes: 4

Views: 910

Answers (1)

PMF
PMF

Reputation: 17248

(See also New SDK project missing "Start External Command" in visual studio. )

There's a new "launch profiles" dialog. You find it either by clicking there: either here or on the small down arrow next to the "Start project" element in the toolbar (and then choose the last element in the menu): enter image description here

In this new dialog, you can create an arbitrary number of startup configurations with different startup parameters. Very helpful for debugging console applications. To add a new configuration, click the "New project configuration" icon in the top left corner. Each entry can have different command line options. To choose which one to start, tick it in the drop-down menu of the start button.

Upvotes: 1

Related Questions