debuggingexevisual-studio-2022

How to use visual studio to debug a local .exe file without project/sln file?


I know how to debug a VS (VC++) project, but what if I have an exe which compiled by other command line without a VS .sln/.proj file?

The .exe is compiled with debug infomation, and I have the source code locally, but I just don't have a vs .sln for it.

In this case, if I want to debug it using VC++, how can I do it?

What kind of solution/project should I create? Let VS open a folder (the source files) maybe?

How to launch (other than attaching) an exe file and debug it?

I'm using VS2022.


Solution

  • If you want to debug a local.exe without project/sln file, you can use the "Open Folder" feature that enables you to open a folder of source files.Please check the following step:

    1.On the Visual Studio menu bar, choose File > Open > Folder, and then browse to the code location.(your source code)

    2.Right-click on the executable in Solution Explorer and select Add Debug Settings. This will open an existing launch.vs.json file.

    3.To start debugging, choose the executable in the debug dropdown, then click the green arrow. enter image description here For more information, please read the following docs:

    Configure debugging parameters with launch.vs.json.

    Debug an app that isn't prat of a visual studio solution

    Hope it can help you.