here is my solution, I tried everything I've seen on internet but this worked for me:
go to launch.json file and you will see
"program":"C:\....\build\debug\outDebug",
change this as:
"program": ""${fileDirname}\\${fileBasenameNoExtension}.exe"
this solution worked for me.
I'm using windows 11 and installed msys2 as vscode's own page recommended. also make sure that the build has done succesfully and a task.json file has created in vs code file in your repos.
I'll also share vs code and youtube link that helped me a lot, so maybe you can find what you're looking for:
Configuring the C++ extension in Visual Studio Code to target g++ and gdb on a MinGW-w64 installation
code.visualstudio.com