There is documentation about this (however it seems to be a bit outdated):
Basically you need to start Visual Studio using the launcher:
If you want to debug your own extension then you’ll need to add AdditionalLauncherSettings. The way I open VS for debugging SlicerRT:
.\S4D\Slicer-build\Slicer.exe --VisualStudio --launcher-no-splash --launcher-additional-settings ./SlicerRT_D/inner-build/AdditionalLauncherSettings.ini c:\d\_Extensions\SlicerRT_D\inner-build\SlicerRT.sln
It also opens the solution.
Then you need to set basically any project as startup, then set the command to
then just start debugging.