nugetsourcelink

Difference between Source Link and a NuGet symbol package


While debugging I can step into external dependencies and our own nuget packages, if they were compiled to symbol packages (MyProject.snupkg) and uploaded to the nuget server. This is how we do it for our own nuget packages on our private nuget server.

I discovered the Source Link tool, whose readme states

Source Link enables a great source debugging experience for your users, by adding source control metadata to your built assets

What is the difference between that and the setup I've described above? And is there a benefit to using both at the same time?

(I've found existing SO questions for configuring Source Link, but none about the difference to symbol packages.)


Solution

  • I consider Source Link as some kind of evolution from symbol packages.

    With the symbol packages, you always had two files:

    So basically the debug symbols are shipped as a separate NuGet package (the snupkg file) and the relationship to the underlying source code is broken. Microsoft lists some more constraints (see here).

    Now since a lot of source code is open anyway (e. g. on GitHub), why not link the NuGet package directly to the sources? That's what Source Link does: it bridges the gap between the referenced assembly and its source code, without relying on an intermediate file (like snupkg).
    This enables true deterministic builds, i. e. one can verify which Git commit was used for an assembly of a NuGet package.