Skip main navigation

Demo – Introduction to Package Management Part 2

.
17.2
Hi. My name is Colin from Northwest Cadence. In this intro video, I’m going to briefly introduce package management in Visual Studio Team Services, or VSTS. Let’s talk a bit about consuming packages. Clients would typically instal packages. They would connect to a feed, then select a package and version, and then instal the package. This typically creates an entry in a package list of some sort since the packages are not typically checked into Source Control. So if you don’t check your packages into Source Control, how does your continuous integration build server get access to those binaries? This is done in a process called restoring. The build needs to know where to find the feeds.
59.5
In other words, it needs the address of the feeds that you’re using. And then it will perform a restore to restore the packages before compiling the rest of the project. Here, I’ve got a repository called AwesomeConsole. Again, the code is not very important for this demo. It’s got some code. And to that code, we want to add a package that we’ve published to a package feed. Here in our package feeds, we have a feed called Demo that’s got an AwesomeLogger package. We created this package and published it to the feed in the first video. Please review that if you haven’t yet seen it. Let’s switch over to Visual Studio and see how we can instal this package.
100
So, here I am in Visual Studio, and I’ve opened up our AwesomeConsole. Here in the main method, I’d like to use the logger. Let’s instal the logger via NuGet. I’ll go to the Solution Explorer, right-click the solution file, and select Manage NuGet Packages for Solution. This will bring up the Visual Studio NuGet Package Manager extension. On the right-hand side, we have a gear icon for configuring our package sources. Let’s go and add a new package source. I’ll click the Plus button. And we’ll call this VSTS Demo Feed. And then we need the URL for that feed. Let’s go back to VSTS and copy the URL for that feed. I’ll click Connect to Feed and copy out the URL.
153.7
Let’s paste that as the source in Visual Studio. We’ll click OK. Let’s then select the VSTS Demo Feed. Because this feed is secured, we’re going to need to sign in to an account that has access to the VSTS team project and to that feed. Now that we’ve authenticated against the feed, we can see the AwesomeLogger package. Let’s click on it. Click on the AwesomeConsole project, and select Instal. You can see we’ve successfully installed the AwesomeLogger to our project.
189.9
If I expand the references, you can see we have a reference to AwesomeLogger. You can also see that Visual Studio has added a packages.config file. This file contains a list of all the packages that are installed in the solution. The automated build system will use this to restore packages so we don’t have to include our packages in Source Control. Let’s go back to Programme.CS and add in our code. We’ll fix up the reference. And you can see we’ve successfully referenced and used our AwesomeLogger. Before we commit this code and do an automated build, we need to set up one more file.
225.1
When the build system comes to restoring our packages, it’s going to need to know the address of the feeds that we’re using. Let’s right-click the solution and select Open Folder in File Explorer. And here, we’ll create a new file. And we’ll call this NuGet.config.
248.9
Let’s open it up in Visual Studio. I’m going to paste some XML. This is a standard NuGet configuration file. Within the package sources, we’re going to need to add a key to our VSTS package feed. Let’s add an Add element.
268.6
The key is DemoFeed. And the value is the URL to our VSTS feed.
277.8
Again, we’ll paste it from our VSTS package feed.
286.3
With that in place, let’s commit and create a build.
293.6
I’ll make sure that nuget.config, packages.config. And the change to our project and our Programme file are all included. We’ll type in Adding AwesomeLogger. And we’ll commit all and push.
312.4
That’ll push our changes up to the demo branch for the AwesomeConsole. Let’s switch over to VSTS and create a build. Here in VSTS, we can see our AwesomeConsole repository. We can see the nuget.config file. Let’s go and create a build for this branch. We go to the Build hub and create a new build.
339.4
Select Visual Studio from the templates. Make sure we have the correct repository and branch.
350.2
We’ll select Continuous Integration to make sure the build triggers every time we push to that repo. Now, the only change we really need to make is to specify the nuget.config file. Let’s browse to the nuget.config file we checked into Source Control.
367.4
Let’s save and give this build a name.
377.8
And finally, let’s queue the build.
392.5
Our build has completed successfully. Let’s click on the NuGet Restore step to see the NuGet restore log. And here, you can see that NuGet has used our package feed that we’ve specified in the NuGet configuration. And it’s managed to restore the AwesomeLogger 1.0.2 to our project. In this video, I showed you how we can Instal a package from our VSTS feed and how we can configure the builds to be able to restore that package during automated builds.

In the second part of the video, Colin Dembovsky from Northwest Cadence introduces how to consume a package in Visual Studio Team Services (VSTS).

Consuming Packages

Install the package

  • Connect to a feed
  • Select a package (and version)
  • Install the package
    • Updates a package list
  • Packages are not typically checked into Source Control

Packages in CI

  • Build needs to know where to find the feed(s)
  • Performs a restore to restore the packages

In the next step, we will watch a video presented by Alex Mullans from Microsoft and learn about Npm and Continuous Delivery in Package Management.

This article is from the free online

Microsoft Future Ready: Fundamentals of DevOps and Azure Pipeline

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education