3

I'm attempting to debug C# code I'm consuming via nuget packages, using VS2015. The package contains the DLL, PDB, and source code for the DLL in the following structure (suggested by the Nuget docs):

> lib
    > portable.etc.etc
        > x.dll
        > x.pdb
> src
    > *.cs
    > **/*.cs (etc.)
> x.nupkg

In the bin/Debug folder of my application, I can see the .pdb files copied out with the DLLs. From my understanding (of documentation about Visual Studio's debugger), the debugger should look in the same folder as the DLL for a PDB of the same name (or matching hash).

When I set a breakpoint using this configuration and try to step into the nuget package's code, a file explorer opens asking me to find the source file. If I do select the source file that shipped with the nuget package, I am able to set breakpoints but the debugger never stops on them. Thus, it seems to me that the PDBs are not being used at all.

Compiling the consuming program in Debug, nuget packages are also built in Debug configuration.

Enable Just My Code is unchecked.

How do I get Visual Studio to use the PDBs from the nuget package?

----------- UPDATE -------------------

Got it using the PDB from bin/Debug, after fixing some wacky configurations that were set by default in VS. (Address level debugging off). However, it still makes me search for the source file in a file explorer. Is there no way for VS to automatically open that source file, or is opening the file manually a burden my nuget package consumers will have to bear? To clarify, PDBs are loading automatically. I want to automatically load C# source files that VS is instead making me look up manually in a file explorer.

Matt
  • 25,467
  • 18
  • 120
  • 187
Dagrooms
  • 1,507
  • 2
  • 16
  • 42

2 Answers2

3

Try disabling Just my code in debug settings, then navigate in Debug -> window -> modules and load symbols for the external package

Enrico
  • 61
  • 4
  • Run the solution and modules should appear – Enrico Feb 07 '17 at 22:16
  • Interesting, I'm seeing `bin\Debug\x.pdb: Symbols loaded.` Pressing `Step Into` gives me a page of disassembly. – Dagrooms Feb 07 '17 at 22:19
  • In Debug settings "enable address-level debugging" is checked? – Enrico Feb 07 '17 at 22:22
  • `Address level debugging` was checked - I unchecked it, it says `file.cs not found -> browse and find file.cs` – Dagrooms Feb 07 '17 at 22:23
  • After browsing to add my file it is letting me set a breakpoint and step through. Should it not automatically find the file.cs that was included with the nuget package though? Is that just a burden my nuget package consumers will have to bear? – Dagrooms Feb 07 '17 at 22:27
  • Will mark your answer correct once we figure out if it will automatically open the source code file, not letting you go back in the Meeseek box just yet. – Dagrooms Feb 07 '17 at 22:28
  • If Debug works correctly when you manually open pdb files, try following this guide: https://msdn.microsoft.com/en-us/library/x54fht41(v=vs.100).aspx – Enrico Feb 07 '17 at 22:33
  • Is that referring to .pdb files? I can load the .pdb files automatically, I cannot load the .cs files automatically. – Dagrooms Feb 07 '17 at 22:46
  • Search for Debug source files in solution properties – Enrico Feb 07 '17 at 22:51
  • Works, thanks. Will probably script that out as post-install off my nuget package. You've been a huge help – Dagrooms Feb 07 '17 at 23:03
  • It turns out my client's problem is that they're debugging a Xamarin for Android application, which uses MDB files, not PDBs. – Dagrooms Feb 08 '17 at 14:13
  • Look at these 2 answers: http://stackoverflow.com/questions/13499384/is-it-possible-to-debug-assemblies-compiled-with-mono-xbuild-with-visual-studi – Enrico Feb 08 '17 at 14:21
3

You need to make sure that you have "Enable Just My Code" unchecked to step through third party .pdb files.

Go to: Tools -> Options -> Debugging -> Uncheck "Enable Just My Code"

It will read the source information from the pdb if available and matches. The pdb file should match the corresponding dll file to work properly, meaning from the same build.

enter image description here

SteveD
  • 819
  • 7
  • 13