Skip to content

Commit c2ba746

Browse files
authored
Add instructions to debug CLI builds using VS (#108455)
Adds instructions to use VS as a tool to debug CLI builds Previously the coreclr debugging docs only mentioned workflows for Visual Studio which involve using VS for both building and debugging. This adds an additional method to build using CLI scripts and use VS to only debug. Thank you @AaronRobinsonMSFT for showing me this method.
1 parent 0d86380 commit c2ba746

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

docs/workflow/debugging/coreclr/debugging-runtime.md

+13
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* [Debugging CoreCLR on Windows](#debugging-coreclr-on-windows)
44
* [Using Visual Studio](#using-visual-studio)
55
* [Using Visual Studio Open Folder with CMake](#using-visual-studio-open-folder-with-cmake)
6+
* [Using Visual Studio to debug CLI builds](#using-visual-studio-to-debug-cli-builds)
67
* [Using Visual Studio Code](#using-visual-studio-code)
78
* [Using SOS with Windbg or Cdb on Windows](#using-sos-with-windbg-or-cdb-on-windows)
89
* [Debugging CoreCLR on Linux and macOS](#debugging-coreclr-on-linux-and-macos)
@@ -103,6 +104,18 @@ Steps 1-9 only need to be done once as long as there's been no changes to the CM
103104

104105
Whenever you make changes to the CoreCLR source code, don't forget to invoke the _Install_ command again to have them set in place.
105106

107+
#### Using Visual Studio to debug CLI builds
108+
Visual Studio can also be used to debug builds built externally from CLI scripts.
109+
110+
1. Build at least the `clr` and `libs` subsets as described in the [build instructions](https://github.com/dotnet/runtime/blob/main/docs/workflow/README.md#building-the-repo). Example command: `.\build.cmd -subset clr+libs -configuration Release -runtimeConfiguration Debug`
111+
2. Build the Core_Root as described in the [testing instructions](https://github.com/dotnet/runtime/blob/main/docs/workflow/testing/coreclr/testing.md#building-the-core_root). This generates `corerun.exe` which serves as the entry point to run managed code. It is placed inside the core root folder along with all required dlls. Example command: `.\src\tests\build.cmd generatelayoutonly`
112+
3. Launch a Visual Studio instance and select the option to open an existing project/solution. Select `artifacts\tests\coreclr\<OS>.<arch>.<configuration>\Tests\Core_Root\corerun.exe` as the project. Alternatively, launch Visual Studio using `devenv /debugexe artifacts\tests\coreclr\<OS>.<arch>.<configuration>\Tests\Core_Root\corerun.exe`
113+
4. In the Solution Explorer, right click `corerun` and select properties. Set `Debugger Type` to `Native Only`. Set the `Arguments` field to a path of a managed application to debug.
114+
5. To set breakpoints, runtime source files can to be added by right clicking the solution in the Solution Explorer and selecting Add -> Existing Item.
115+
6. Set breakpoints and run the application with `F5` to start debugging.
116+
117+
Note, the `.sln` file can be saved and stores paths to `corerun.exe`, included files, and debug settings. It can be reused as long as the paths do not change.
118+
106119
### Using Visual Studio Code
107120

108121
It will be very nice to be able to achieve all this using Visual Studio Code as well, since it's the editor of choice for lots of developers.

0 commit comments

Comments
 (0)