Skip to content

SourceLink

Maria Furman edited this page Apr 19, 2018 · 3 revisions

What is SourceLink?

SourceLink allows source code to be downloaded on demand when debugging.

How do I use it?

As of Wilson 5.2.2, SourceLink is enabled in our release builds (so there's nothing you need to do!).

However, if you're interested in including SourceLink in your own project, the simplest way is to include this nuget PackageReference in every project that you want SourceLink enabled for:

<Project>

    <ItemGroup>

        <PackageReference Include="SourceLink.Create.CommandLine" Version="2.8.0" PrivateAssets="All" /> 

    </ItemGroup>

</Project>

Then, at build time, simply make sure that the property /p:SourceLinkCreate=true is set for either dotnet.exe or msbuild.exe. This will embed a JSON configuration file that contains information about the original source code in the PDB, allowing Visual Studio (and other debuggers) to retrieve it from GitHub or other hosted services. More information on using SourceLink can be found in the official SourceLink documentation provided in the Additional References section at the bottom of this page.

How do I know SourceLink is working?

If you're using a library that has SourceLink enabled and you don't already have access to the original source files, you will see the following prompt if, for example, an exception is thrown:

We have confirmed that this works properly with Visual Studio 2017, but according to the SourceLink documentation it is also supported by Visual Studio Code, JetBrains dotPeek, and JetBrains ReSharper.

Additional References

SourceLink GitHub repo/README:

https://github.com/ctaggart/SourceLink

SourceLink Wiki:

https://github.com/ctaggart/SourceLink/wiki

SourceLink spec:

https://github.com/dotnet/designs/blob/master/accepted/diagnostics/source-link.md

Clone this wiki locally