Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enabling SourceLink

Having private repositories on VSTS (Azure DevOps) I tried enabling SourceLink by adding the following to the .csproj file: https://github.com/dotnet/sourcelink#azure-devops-visual-studio-team-services

This does not seem to have any effect during debugging. There is an exception thrown in a local NuGet package and I can not navigate to it using the Call Stack windows since the pdb is not even loaded for that project.

I have "Enable Just My Code" disabled and SourceLink enabled inside Visual Studio.

What other changes do I need to make to enable SourceLink?

like image 973
Răzvan Flavius Panda Avatar asked Sep 02 '25 13:09

Răzvan Flavius Panda


1 Answers

This may not be a direct answer, but it is well worth noting that you don't need SourceLink to get source level debugging. SourceLink is a clever way to put links in the PDB to source code in the cloud, in a git repo.

Another way to get portable source level debugging is to embed the source code directly in the PDB (EmbedAllSources=True), then embed the PDB in the DLL (DebugType=embedded). It's fairly efficient (20-30% larger .nupkg file) and doesn't suffer from the bug currently affecting separate PDBs.

Just add this to your project file:

  <PropertyGroup>
    <EmbedAllSources>True</EmbedAllSources>
    <DebugType>embedded</DebugType>
  </PropertyGroup>

and lo and behold you will be able to single step into the NuGet file generated from it. No other workarounds and no SourceLink packages are required.

like image 155
MikeBeaton Avatar answered Sep 05 '25 03:09

MikeBeaton