Debugging into NuGet packages
This is a straightforward article that describes how you can step into a NuGet package while debugging your project. I’m assuming that you have access to the source code for the package.
First, you need to allow Visual Studio to debug other people’s code.
Choose Options from the Tools menu. Under the General section of the Debugging node, untick the box for “Enable Just My Code”.
Next, under the Symbols section, you need to tell Visual Studio where to find the symbols file for the NuGet package. (This could be under your local “.nuget/packages” folder.) In the list of symbol file locations, add a new item and enter the file path to the .pdb file of your package. Make sure the box for this item is ticked.
Locating the source
Start the debugger and try to step into code from the NuGet package.
The first time Visual Studio needs the location for a .cs file, it will pause debugging and prompt you to browse for the file. If this happens, simply navigate to your source code for the package and choose the file from there. Hint: If you need help finding the file in the project, the file dialogue displays the original location at the top.
You should now be able to step into the source.
Used for this article
- .NET 5
- Visual Studio Enterprise 2022