3

I'm currently working on a home grown .NET Core project. A developer in another division has created a NuGet package that has a lot of core functionalities. I was instructed that I should consume the package in my project to allow for shared code. I was sent the 2 files.

  1. HomeGrownNuget1.nupkg
  2. HomeGrownNuget1.symbols.nupkg

so in Visual Studio I went into Manage Nuget Packages for Solution -> Added a new Package source and pointed it to the local file where I stored the 2 files. Added Local Nuget Source location Then I browsed to the NuGet package and installed it.

However, when I run the program, I still cannot step into the logic in the NuGet package.

What is the proper way to get this to work?

Pang
  • 9,564
  • 146
  • 81
  • 122
Joe Ricklefs
  • 584
  • 4
  • 24

1 Answers1

1

If you want to debug a nuget package, there are some things that you (the consumer) should do and some things that the publisher should do. Guidance taken from this.

  1. Publish the nuget package with symbols

    dotnet pack [PROJECT].csproj --include-symbols --include-source
    
  2. Setup debugger under Go to Tools -> Options -> Debugger -> General

Uncheck “Enable Just My Code (Managed only)”.

Uncheck “Enable .NET Framework source stepping”. Yes, it is misleading, but if you don't, then Visual Studio will ignore your custom server order (see further on).

Check “Enable source server support”.

Uncheck “Require source files to exactly match the original version”

Go to Tools -> Options -> Debugger -> Symbols. Select a folder for the local symbol/source cache. Add symbol servers under “Symbol file (.pdb) locations”. Pay attention to the correct order, because some servers may contain symbols for the same binaries: with or without sources.

Pang
  • 9,564
  • 146
  • 81
  • 122
Athanasios Kataras
  • 25,191
  • 4
  • 32
  • 61
  • I am able to debug into it now. But Not its telling me," Cannot obtain value of the local variable or argument because it is not available at this instruction pointer, possibly because it has been optimized away." – Joe Ricklefs Dec 12 '19 at 15:15
  • Check this: https://stackoverflow.com/questions/8311303/cannot-obtain-value-of-local-or-argument-as-it-is-not-available-at-this-instruct/16338249 it must be done for the nuget package. Create a pre release package and when you are ready for production, create the optimized version again. – Athanasios Kataras Dec 12 '19 at 17:30