Debugging packages from your VSTS Package Management Feed with Visual Studio 2017

In this blogpost I am going to show you how you can debug packages that reside in a Package Management Feed in Visual Studio Team Services (VSTS).

Setting the stage
The package represents a custom build package that can serve any generic functionality used by other applications. The package has its own solution and is automatically pushed to the Package Management feed by a CI Build.

In another solution we have an command line application that consumes this package and we like to have the ability to be able to debug through that code without having to do any other plumbing. We want to treat the package as if we don’t know where the source is.

Pre-requisites
There are some pre-requisites to this, you need to have Package Management in VSTS. AND there is the need to have the private preview of the Symbol Server for VSTS. This can be requested here: https://docs.microsoft.com/en-us/vsts/package/symbol/setup. A public preview is to be expected, so be sure to keep an eye out for this!

Setting up the Package creation Build
Publishing the package to the VSTS feed is fairly straightforward. I use a PowerShell script verion my package assembly as well as applying that version to my packages. This way every package gets a new version and is easily traceable. Let’s check the steps that are involved in this build.

Packages Build Details

First I run my versioning PowerShell script. An environment variable is set in the script (real production usage work needs a bit of tweaking) and that environment variable is used during the NuGet Pack operation to version the package.

After that the symbols are published. This is a mandatory step to get the debugging running.
The symbols are published to a new Symbol Server Type: Team Services. This is a hidden area in VSTS that will store your PDB files.

Packages Publish Symbols

The result of a successful build is that we see a new package deployed to the feed, with the desired versioning scheme, but more importantly we see that the Artifacts of this particular build are enhanced!

Packages Build Artifacts

We see that besides the usual drop artifact there is another artifact available. This artifact is not downloadable nor explorable but this artifact contains the valuable PDB files that allow us to debug the package!

Consuming the package
Consuming our created package is like any other NuGet package but this one comes from your VSTS Package Management Feed. The location of the feed can be configured in Visual Studio.

In my Package Consumer I have just a reference to the package, as can be seen in my installed packages overview.

Packages Installed

Debugging the package
Now lets hit F5 and debug to some lines of code;

Packages Own Code

The Mammal class is defined IN the package, that usually would be a blackbox to me but since this is my own package I can now easily step into the code without having to setup anything else!

Packages Debug Package Code

This is really cool, easy and very convenient! Happy Debugging!

Little warning…
There are some quirks in the private preview. One involves authentication against your VSTS environment. This was resolved in the latest Visual Studio Update 15.4.2. The following post refers to the issue; https://developercommunity.visualstudio.com/content/problem/93310/source-code-does-not-load-via-source-server-for-sy.html

Getting the code
All the code is placed on GitHub in following repositories:
Package Solution: https://github.com/JasperGilhuis/Package
Package Consumer Solution: https://github.com/JasperGilhuis/Package-Consumer

One Reply to “Debugging packages from your VSTS Package Management Feed with Visual Studio 2017”

  1. Hi Jasper, good post!! Thank you very much for your effort. I am trying to setup my environtment. It is like yours but i have code in vsts repos instead of github repos. I havent been able to do it work because i always receive and error when i try to debug into the nuget code. The error says that debugger can not find the source file and it shows a path of vsts agent server. Could you help me?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: