Using currentDir
, for example:
{
"version": "0.2.1",
"defaults": {},
"configurations": [
{
"type": "default",
"project": "CMakeLists.txt",
"name": "testd.exe (Debug\\testd.exe)",
"currentDir": "${workspaceRoot}\\app_home",
"args": [
"${workspaceRoot}\\app_home"
]
}
]
}
The reason why VS_DEBUGGER_WORKING_DIRECTORY not working is:
When we use VisualStudio IDE to manager a project, it just a text editor.
For example a cmake project, the IDE just running cmake
command by params in CMakeSettings.json
Then if we choose ninja
, it will not generate the .sln and .vcproj files, just using build.ninja to drive build process.
If we choose Visual Studio 2019
, it will generate a .sln file and some .vcproj file, but these file just a middle step of building. The current VS-IDE window will not load these file, just use command line to utilize the vcproj/sln file to build.
The VS_DEBUGGER_WORKING_DIRECTORY
would saved into these middle-step .vcproj files, that invisible of current IDE windows. (Remember: The current IDE windows just a text editor of CMakeLists.txt)
In other words, it doesn't matter between using VS-IDE with cmake and makefile.
Note: We can see the build process in Output window.

Note:
Whether we choose Ninja or VisualStudio2019, the backend build tools are same, MSVC.
But how can we use VS-IDE property?
Just open the middle-step .sln and Visual Studio will automatically sync these two windows.