Copy NuGet .pdb to output directory
Asked Answered
R

1

6

When I build an ASP.NET Core project it copies to the output directory only its own .pdb files and all .dlls of any installed NuGet packages. However, it does not copy their .pdb files. I have to select them manually from the %UserProfile%\.nuget\packages directory.

I was wondering whether there is an option to enable NuGet package .pdb to be copied to the output directory?

Ribbentrop answered 18/2, 2018 at 15:31 Comment(0)
G
4

The new way of doing this is, increasingly, to use SourceLink, which allows source code to be downloaded on demand while debugging.

NOTE: At the time of this writing there are still missing features, as pointed out by Martin Ullrich.

NuGet Symbols Packages and Symbols Servers

Traditionally, there were no .pdb files in NuGet .nupkg files.

Instead, the .pdb files were put into NuGet symbol packages (ending in .symbols.nupkg).

They can then be hosted on symbol servers (or the local file system), which can in turn be used by the Visual Studio IDE by configuring it accordingly. See also Specify symbol (.pdb) and source files in the Visual Studio debugger.

Do note that not all NuGet package publishers create symbols packages or use SourceLink - if you need to debug an open source library that doesn't have any, perhaps you should consider contributing them.

Gatias answered 18/2, 2018 at 16:38 Comment(7)
Actually they are my own packages that contain .pdb files but the alternative with the NuGet symbol packages (which is new to me) sounds very interesing and it looks like the right way for using .pdb files.Ribbentrop
I'd actually say that including the pdb files is increasingly the better way of handling this - using Source Link to link the PDB to the source code itself. This removes the dependency on the symbol servers.Correction
It's actually a missing feature and should be available in 2.1.300+, see tracking issue github.com/dotnet/sdk/issues/1458Humidistat
@nl-x: If the approach in the answer doesn't work for you, I'd need to look into exactly what's going on. But be aware that not everything needs to be in an output directory for .NET Core - I'd expect it to possibly not be there, but be in a publish directory. So try running dotnet publish and see whether that's any better.Correction
@nl-x: Using SourceLink, I'd expect the PDB to be in the NuPkg file already - for example in the NuPkg file for nuget.org/packages/Google.Cloud.Speech.V1. If the package's publisher didn't use either symbol servers or include the PDB file in the package, that's not something that can really be fixed by the consumer. But if the PDB file is in the package already, I'd expect the debugger to be able to pick it up. At this stage I think you'd be best off asking a new question describing your exact situation, rather than doing it in comments here.Correction
@nl-x: Again, please ask a new question, describing your exact situation - what you've tried, and what's not working. Normally this just works out of the box.Correction
@nl-x: How do you know their exact situation? You don't know what version of .NET they're targeting, what packages are involved, exactly what happened when they started debugging, etc. At least, none of that information is in the existing question. That's what should be in your new question. Please, please do not add any more comments on this answer, unless it's a link to a new question. Stack Overflow comment threads are not designed for this sort of extended discussion.Correction

© 2022 - 2024 — McMap. All rights reserved.