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 i
Well, I should have read and followed this answer before posting my question because this was the missing piece of the puzzle.
I needed to follow steps 5 and 6 of Eric's blog post but I actually didn't need to modify my pack
command because I'm not including the .pdb
file in the Nuget Package.
Note: So far I could only get this working if the Nuget Package is generated with the Debug Build Configuration. If you find a way to get Source Link working with a Release DLL inside the Nuget Package, please answer my other question. Thank you
This requires two things:
.pdb
) which is a mapping file used by the debuggerFor each project in your solution:
Only if you plan consumers of the Nuget package to use Visual Studio 2017. This step isn't required with you want to use Source Link with Visual Studio 2019:
In Visual Studio, right click on your project -> Properties
then go to Build -> Advanced
and change the Debugging Information
from Portable
(default value) to Full
Install the Microsoft.SourceLink.AzureDevOpsServer.Git Nuget Package
Edit the .csproj
file and include the following code in the first PropertyGroup
element:
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
Create a pipeline variable called BuildConfiguration
(if it doesn't exist already) and set the value to Debug
.NET Core Build
task: --configuration $(BuildConfiguration)
.NET Core Pack
task, use this variable in the Configuration to Package
field: $(BuildConfiguration)
At the end of your pipeline you must have a task Index Sources & Publish Symbols
Artifact name
field, the BuildConfiguration
variable must be used too: Symbols_$(BuildConfiguration)
Of course you must also have a .NET Core Push
task to push you Nuget package to your Azure DevOps Nuget Feed
Tools -> Options -> Debugging -> Symbols
click on the New Azure DevOps Symbol Server Location...
button and authenticate to the server
C:\Symbols\
. This is where all your .pdb
files will be storedTools -> Options -> Debugging -> Symbols
click on Load only specified modules
. You can here specify the Symbol files of DLLs you want to load.
If you don't do this and leave the default to Load all modules, unless excluded
, Visual Studio will take a very long time to load everything when you run your program in debug mode.
Tips : To see all the DLLs loaded by your project, when you're debugging, click on Debug -> Windows -> Modules
. From here you can view the full list, select multiple and then right click Copy Value -> Copy Name
Tools -> Options -> Debugging -> General
Enable Just My Code
Enable source server support
Enable Source Link Support
When you want to debug inside the Nuget Package's code, naturally press F11
to step into it and Visual Studio will ask if you agree to download the source code from your Azure DevOps repository