In Visual Studio 2015 and .NET Core development we could debug NuGet packages by retrieving the source code from a source (e.g. GitHub) to a local disk, adding the source path to the downloaded source code in global.json
and reference the NuGet package in our project. This caused a reference to the projects in the downloaded source code to automatically be visible in the current solution and thus made it possible to easily debug (More about this functionality can be read about in this article).
Does anyone know how to do the same using Visual Studio 2017? Since the global.json
is gone I can't find any solution for this.
The easiest way to debug your nuget packages is to put the . pdb files of the packages in the build output folder of the project you want to debug. If the code you are trying to debug is classified as non-user code you need to uncheck Just My Code in the debugging options.
In order to debug into NuGet package libraries, Visual Studio must be configured to use ProGet as a symbol server. To do this select Debug > Options, from the menu bar, then browse to Debugging > Symbols in the tree menu.
I see this has become a popular question, however, MS is (as for the most time nowadays in Visual Studio) absent in requests that actually can improve their product.
There are some posts around out there on how to use the reference library from Microsoft, but this doesn't apply to all projects plus you will debug optimized release bits which is limiting in both watch and step capabilities. I also feel that this way to do it even slows down a slow Visual Studio even more. This way to do it is described in this post.
However, lately I have found a way to work around this issue. It isn't always stable, but what can be done is to add the related project to your project as a project reference.
But here are the steps I have done that mostly works:
Build and debug, in your output window check that the assembly located in your project's output folder is used. If it is, just hit breakpoints in the referenced projects and you'll have full debug functionality.
It is a bit of trying and failing to make this work, but it does work eventually.
It is possible to create conditions on the project references to ensure that they isn't built in e.g. release builds, however, be aware that changing configuration requires that you reload your solution AFTER the change!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With