2018-06-27

Newtonsoft.Json enabling Source Link

Newtonsoft.Json 11.0.3 will be packaging the pdb files with source link enabled. It is the most downloaded package at nuget.org. Anyone using the new version may step into the source code using a debugger that supports source link such as Visual Studio 2017:


That video is from January when I opened a pull request to enable source link using SourceLink 2 tools. 5 years ago, I actually opened a pull request to enable source link using SourceLink 1. The pull request that I assisted James with is using the new Microsoft.SourceLink 1 beta tools.

Microsoft.SourceLink

SourceLink joined the .NET Foundation in November and now has a new home at https://github.com/dotnet/sourcelink/.  New tools are shipped in the NuGet Gallery as Microsoft.SourceLink.* 1.0.0-beta*. They currently work on Windows and Ubuntu, but will soon support the rest.

Most of the SourceLink 2 tools are made obsolete by the .NET SDK 2.1 and Microsoft.SourceLink tools. My repository will still continue to fill in gaps in tooling. SourceLink 3 tools will be tools that build on top of the .NET SDK 2.1.

dotnet tool install --global sourcelink

The first and only tool for SourceLink 3.0 tools is a sourcelink command-line tool for testing for source link support.
install.txt loading ...

help.txt loading ...

You can print the json:
print-json.txt loading ...

You can test downloading all the source files for every document in the pdb:
test-pdb.txt loading ...

You can test every pdb in a nupkg:
test-nupkg.txt loading ...

How to enable source link for your library

Follow the instructions in the readme. I think the simplest solution that will work for many projects is to add a Directory.Build.props in your source directory that looks like this:

Directory.Build.props loading ...