5

I'm trying to create a debugger nuget package. So, I start with "Creating symbol packages". Create package using nuget pack PackageARM.nuspec -Symbols

PackageARM.nuspec:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
  <metadata>
    <id>PackageARM</id>
    <version>1.0.15</version>
    <authors>PackageARM</authors>
    <owners>PackageARM</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Package Description</description>
    <dependencies>
      <group targetFramework=".NETStandard2.0" />
    </dependencies>
  </metadata>
  <files>
        <file src="bin\Release\netstandard2.0\*.pdb" target="lib\netstandard2.0" />
        <file src="bin\Release\netstandard2.0\*.dll" target="lib\netstandard2.0" />
        <file src="**\*.cs"  target="src" />
    </files>
</package>

And push it to nuget: https://www.nuget.org/packages/PackageARM/1.0.15

Then uncheck Enable Just My Code and check Enable source server support in VS 2017. Also I tried to add symbol servers: https://www.nuget.org, https://nuget.smbsrc.net/ but no result.

When I try step into method from package using F11 it just step to the next line. What I missed?

My pdb file contains path to .cs file that is 'C:\project\ProjectARM\Class1.cs' it is ok? how can other users debug if the doesn't have that path with source?

Community
  • 1
  • 1
Robert N. Dean
  • 1,219
  • 1
  • 14
  • 27
  • You didn’t push the symbols yet. – Lex Li May 04 '18 at 21:59
  • @LexLi No, I've pushed. > nuget push PackageARM.1.0.15.symbols.nupkg -source https://nuget.smbsrc.net/ Pushing PackageARM.1.0.15.symbols.nupkg to the symbol server (https://nuget.smbsrc.net/)... POST https://www.nuget.org/api/v2/package/create-verification-key/PackageARM/1.0.15 OK https://www.nuget.org/api/v2/package/create-verification-key/PackageARM/1.0.15 1290ms PUT https://nuget.smbsrc.net/api/v2/package/ OK https://nuget.smbsrc.net/api/v2/package/ 2631ms Your package was pushed. – Robert N. Dean May 04 '18 at 22:31
  • But I could not list the symbols package with the command line:`nuget.exe list PackageARM -AllVersion -Prerelease -source https://nuget.smbsrc.net`, I could list the symbols package for `Newtonsoft.Json`. Could you list it? – Leo Liu May 07 '18 at 11:03
  • No, but I got "Your package was pushed" – Robert N. Dean May 07 '18 at 12:10
  • @RobertN.Dean, Yes, I noticed you previous comment and I know that you have successfully pushed that symbols package. And I have also successfully push a custom symbols package `PackageARMTest.1.0.1.symbols.nupkg`, but I also could NOT list it from the symbols server, it may be a problem with the server. I have reported this to the nuget team:https://github.com/NuGet/Home/issues/6916. To resolve your question, I would like provide a workaround to you in following answer, you can check if it helps you. – Leo Liu May 08 '18 at 06:41
  • @RobertN.Dean, Got the feedback from Github: https://github.com/NuGet/Home/issues/6916. It looks like a symbol server issue. And have you tried the workaround, check if it works for you. – Leo Liu May 11 '18 at 05:05

2 Answers2

0

how can other users debug if the doesn't have that path with source?

Since you could not access the symbols package from the symbols server, we could not debugging on that way. I would like provide you a workaround to debugging the nuget package.

  1. Put the pdb and source code file in the NuGet package alongside the dll.
  2. Add the source code to the Debug Source Files for the solution that references the package.

More detail on step 1:

I have checked your nuget package on the nuget.org, found that you have already put the .pdb and source code file in the NuGet package alongside the .dll.

More detail on step 2:

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 (Add the path of .cs file in the Packages folder after install the nuget package):

enter image description here

For some more details, please check this thread.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
0

I've struggled with this for a long time. Here's the easiest way that I found that works repeatably:

  • Acquire the source code and build a Debug version of the nuget package locally. You'll need to increment to package version. Hopefully the author has provided a .nuspec to make building easier.

Create a local nuget source:

  • Place the .nuget file that you just created in C:\Nuget (for example)

  • In Visual Studio, select Tools / Options / Nuget Package Manager / Package Sources

  • Press the green (+) icon. Add the path to the local nuget package that you created above (C:\Nuget) and move the package source to the top of the list.

  • In your solution, for each project, remove the previous reference to the external nuget package and add the new nuget package from your local nuget source.

  • Start debugging and you should be able to step into the code for the nuget package.

I'm able to set a breakpoint in the source code from where I build the nuget package and have it break when I run the code.

All of the steps above are a little fidgity and you may need to play with it a few times to get it to work.

Let me know in the comments if this works for you. And if so, I'd appreciate an upvote! :)

Francisco d'Anconia
  • 2,436
  • 1
  • 19
  • 25