There are several documented ways on internet on how to use Symbols Source files and Source Link to debug inside a Nuget Package but it's honestly hard to understand what is the good way for me.
We have an Azure DevOps Server on which we generate Nuget packages and at the same time publish the .pdb
files to the Azure DevOps Symbol Server using an Index Sources & Publish Symbols
task in our build pipelines as described here
My project' also has a reference to Microsoft.SourceLink.Vsts.Git
and this code in the .csproj
file
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
I've read several blog posts but the source I trust the most to be up to date is of course the official Source Link Git repository.
The readme.md
file says
Including PDBs in the .nupkg is generally no longer recommended as it increases the size of the package and thus restore time for projects that consume your package, regardless of whether the user needs to debug through the source code of your library or not
I agree with that point that's why I want to use the Symbol Server, not to include the .pdb
file in the Nuget Package. Therefore please don't flag my question as a duplicate of this one, because the accepted answer is exactly what I don't want to do.
The readme file also states that
.snupkg symbol packages have some limitations:
- They do not currently support Windows PDBs (generated by VC++, or for managed projects that set build property DebugType to full)
- They require the library to be built by newer C#/VB compiler (Visual Studio 2017 Update 9).
- The consumer of the package also needs Visual Studio 2017 Update 9 debugger.
- Not supported by Azure DevOps Artifacts service.
so at least I know I can't use that.
But what is the proper way to set Source Link up and working then?
When I debug my test console application it successfully downloads the .pdb
file to my Symbols cache folder but if I try to step in the code coming from my Nuget Package using F11
, it just doesn't work. (However it steps in System.String.Concat
because my simple test Nuget Package is actually concatenating some strings)
I tried to run sourcelink test TestSourceLink.pdb
but I get a error: url hash does not match
. I read here that sourcelink test
is a legacy thing and doesn't support authentication to private repositories like ours.
With my browser, if I visit the URL given by sourcelink print-json TestSourceLink.pdb
I can see the latest source code. But now the question is, why is Visual Studio not able to download the source code? I'm authenticated to this Azure DevOps server in VS because I'm able to install Nuget Packages coming from this server.
Here are my debugging settings:
Thanks a lot. I really can't figure out what's the missing piece of this puzzle
See Question&Answers more detail:
os