Menu
Free Pack
Download BuildMaster Free Trial

What is a Source Server and How Does it Help Debug NuGet?

by Eric Seng, on Feb 9, 2022 10:51:00 AM

Have you ever consulted the source code of an NuGet package for debugging?

Checking the original source files used to build a package can help during the debugging process, especially considering the multiple iterations a NuGet package can go through.

Source serving is not automatically configured, however, in Visual Studio. Some major private repositories don’t even offer source or symbol serving functionality.

In this article, we’ll quickly explain what a source server is, what SourceLink is, and how it can help with debugging NuGet packages.

What is a source server?

Per Microsoft, a source server “enables a client to retrieve the exact version of the source files that were used to build an application.”

A module’s source code changes between versions as it continues to develop over time; patches, major upgrades, etc.. The source server retrieves the appropriate files from the source control server.

To use source server, the application must be source indexed; e.g. must embed version-control path and version-number information into a PDB file. A PDB file, also known as Symbols, helps map the compile code and point to the right file.

A private NuGet repository like ProGet can index and serve PDB files, but will have to be configured ahead of time.

Once your repository is configured for source serving, your dev environment (ex. Visual Studio) must also be configured to allow source server debugging.

What is SourceLink?

The similar names between source server and SourceLink reflect their connection: SourceLink is a technology that allows authors of NuGet libraries (like those who have published to NuGet.org) to provide source debugging for other users.

Instead of embedding information in the PDB files, SourceLink relies on a NuGet package’s metadata element to locate code files in a web-based Git repository.

How does source serving help with debugging?

Source Servers and Symbols go hand-in-hand.

Source indexing help the debugger find the right source files (from the source server). Because the source indexing information is stored in the PDB files, you must have symbols loaded.

If you want to debug into the source code associated with a PDB file, for example, the SourceLink build tool can embed source file URLs (or the files themselves) during compilation.

Better NuGet debugging

There aren’t many ways to debug a NuGet package. Most developers will likely avoid using NuGet libraries than attempt a tedious debugging process.

Symbol and source serving, however, shows it is possible when configured correctly.

Debugging is important, but there’s a lot more to learn about NuGet packages to successfully use them on the Enterprise level. Sign up for our new ebook:

Topics:ProGetNuGet

Related Posts

About Inedo

Inedo is a software product company bringing you the "tech behind the tech."

Makers of Windows-first, enterprise DevOps tools BuildMaster CI/CD, ProGet private package management, and Otter IaC. Maximize developer time, minimize release risk, and empower stakeholders to bring their vision to life faster, all with the people and technology you have right now.

Follow us on social media

Follow Inedo on YouTube Follow Inedo on Facebook Follow Inedo Twitter New call-to-action

Free e-books

Free PowerShell Book NuGet for the Enterprise Guide Jenkins CICD Guide Free CICD Book Free dotnet book free IaC book