3

I have generated some nuget packages containing .pdbs with the following:

<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>

I have verified the .pdbs are within the .nupkg generated in the lib/*/ folder next to the dll's.

However, when I consume these nuget packages in Visual Studio 2017, it only extracts the .dll's and not the .pdb's. Leaving me unable to debug into the package.

What am I doing incorrectly?

Dan
  • 858
  • 7
  • 18
  • Hi Dan, what error message you get when you try start debugging? – LoLance Apr 25 '19 at 06:09
  • It just doesn't let me debug into the library code, because the PDB isn't being copied into the bin directory or used at all. – Dan Apr 25 '19 at 15:41
  • Do you mean you want to debug into the source code? A .nupkg with only .dll and .pdb doesn't support 'step into' source code. You still need source files(xxx.cs) so that you can debug into. Only .dll and .pdb is not enough for that. – LoLance Apr 25 '19 at 16:19
  • That is what I want, I didn't think about how it would work without source, how can I accomplish that with file based nuget repo's(serverless). – Dan Apr 25 '19 at 16:22
  • You can try a nuget command in post-build event like this: nuget pack MyProject.csproj -symbols -Properties "Configuration=Debug" -suffix debug. – LoLance Apr 25 '19 at 17:06
  • Ah see I'm not having trouble with the generation of the packages, my problem it is that I don't want the Consumers of the package(other team members in a local org) to have to do any extra work in order to step through. It looks like there may just be no solution for my exact requirements. – Dan Apr 25 '19 at 17:25
  • You can check if Source links can satisfy your requirements. If you use [source links](https://learn.microsoft.com/en-us/dotnet/standard/library-guidance/sourcelink) as source control. Then the other team members don't need extra work. Just like when we [debug .net core source code](https://stackoverflow.com/questions/55626888/debug-net-core-source-visual-studio-2019/55644394#55644394), the vs will fetch the source files for us automatically without extra work. In this way, the source files are online, and we need the connection to Internet when we try to step into. – LoLance Apr 25 '19 at 17:33
  • But, actually this is not the original question you ask. Hope source links can satisfy your needs. Also, you can have a look at [this .snupkg](https://learn.microsoft.com/en-us/nuget/create-packages/symbol-packages-snupkg). But I'm not familiar with this new package format, just provide an idea. – LoLance Apr 25 '19 at 17:42

1 Answers1

0

Since you can make sure the .nupkg contains the .pdb file. please make sure both the projects are in debug mode.

Consuming a nuget package locally sometimes has some difference from installing it from nuget.org. The .pdb source won't be found in solution. By default, the .pdb will locate under path like :C:\Users\xxx\.nuget\packages\PackageName\xxx.

Update:

  1. If the nuget package project and the project which consumes it is on the same machine. The AllowedOutputExtensionsInPackageBuildOutputFolder property is enough. Since you have source files on same machine, and the debug engine can easily find it so that you can step into it.

  2. But if for a scenario like this: You developed the nuget package. And share it to other team members. To make them can Step into you should embed the xx.cs files into the .nupkg.

Under this circumstances, the AllowedOutputExtensionsInPackageBuildOutputFolder may not work. I can't find a way to embed source files using it. You may need to use a nuget pack command like this issue. Actually, the way Stephan packed the project is correct. I've checked it work and will embed the source files and .dll and .pdb into the .nupkg. Of course, in this way you need to add the path to source files repo by Solution=>Properties=>Debug Source files: enter image description here

In addition: You can add the nuget pack command in a post-build event, so that every time you build a project successfully, it will package for you.

Also, you can consider source links as source control so that you won't configure the source path by Solution=>properties.

LoLance
  • 25,666
  • 1
  • 39
  • 73