2

I have a common project that I build and create a nuget package from, for consumption in my other applications.

The build process for the common project both creates a nuget package, deploys it to our private nuget repo and pushes the symbols to our internal symbol server.

In my "other applications", in this specific case an ASP.NET website, I pull in the nuget package from our repo but when I try to step into code in that assembly it just skips over it. I cleared my local symbol cache and as soon as I start debugging VS pulls in all the symbols from the symbol server so I know that bit is working.

Can anyone help me?

enter image description here

Chris
  • 26,744
  • 48
  • 193
  • 345

1 Answers1

3

You need to publish Nuget package with symbols and refer to them using the Symbols under Tools->Options->Debugging->Symbols.

See HOW TO DEBUG A .NET CORE NUGET PACKAGE?

Other members also asked the similar issue before:

How to debug code in a nuget package created by me

Update:

Since you want to step into code in the assembly, you still need to provide the source code file in the NuGet package alongside the dll.

As we know:

A symbol is a file containing metadata that represent the link between your original source code and the machine code that has been translated by a compiler.

In the Microsoft world, a symbol is represented by a .PDB (Program DataBase) file. It is the heart of the debugging process because thanks to these metadata, the debugging tools are able to correlate the instructions executing in the application to the original source code and providing features like breakpoint or variable watchers.

So if you only provide the dll and .pdb file, you still not step into the code, you also need provide the source code, then add the source code to the Debug Source Files for the solution that references the package:

More detail on providing the source code:

If you're currently packaging without a Nuspec, you'll need to create a Nuspec, then add the pdb to the list of files in the lib folder and source file in the src folder. "NuGet spec" may be a useful command for generating the initial spec as defined in NuGet docs. Below is my .nuspec file, you can check it:

<?xml version="1.0"?>
  <package >
    <metadata>
     <id>MyTestPackage</id>
     <version>1.0.3</version>
     <authors>Admin</authors>
     <owners>Admin</owners>
     <requireLicenseAcceptance>false</requireLicenseAcceptance>
     <description>Package description</description>
     <releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
     <copyright>Copyright 2017</copyright>
     <tags>Tag1 Tag2</tags>
   </metadata>

   <files>
     <file src="bin\Debug\MyTestPackage.dll" target="lib\Net46" />
     <file src="bin\Debug\MyTestPackage.pdb" target="lib\Net46" />
     <file src="Class1.cs" target="src" />
   </files>
</package>

More detail on add the source code to the Debug Source Files:

When you have a solution open, right click on Solution, select Properties...Common Properties...Debug Source Files, and add the root source directory for the relevant binary reference:

enter image description here

Pang
  • 9,564
  • 146
  • 81
  • 122
Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • 1
    Hey thanks for the comment... Symbols are already created and published and are subsequently pulled into my local symbol cache through the means you mentioned. – Chris Feb 21 '18 at 12:51
  • @Chris, thanks for your reply. Have you added the source code in the nuget package? If not, please refer my updated answer for details, check if it works for you. – Leo Liu Feb 22 '18 at 06:47
  • 2
    Leo - thanks for the update. I hadnt set the `Debug Source Files` folder so have done that now, but it hasnt worked. The only other thing I do not do is specify the pdb's in my nuspec file BUT I do publish the PDBs to the Symbol Server (from VSTS) and those PDBs are loaded so can't imagine thats the issue? – Chris Feb 22 '18 at 16:11
  • @Chris, It still not work? What is the error? Could not find the source file? or could not step into the source code? How about specify the pdb's in my nuspec file? – Leo Liu Feb 23 '18 at 06:56
  • 4
    I seem to get no error, it just steps straight over the line as if I pressed F10 rather than F11. I updated my nuspec accordingly but it made no difference. If I open the Modules window all PDBs are loaded correctly for those libraries. The only potential thing worth mentioning is that this is an async method im trying to step into? – Chris Feb 23 '18 at 11:02