Configure Visual Studio Team Services (VSTS) to create Nuget feeds

Any software development team working on a software product generally needs to consume the components either already developed by another team in their organization or another third party organization. So they require a mechanism through which they can create, share and consume the source code. Most often a times, this code is bundled into “packages” that contain compiled code (as DLLs) along with other content needed in the projects that consume these packages.

An Introduction to Nuget

In .NET world, this mechanism has come to be defined by Nuget. It defines how .NET packages are created, hosted, consumed and provides necessary tools for mentioned roles.  In this blog post, we’ll learn how to configure Visual Studio Team Services or VSTS for creating and consuming nuget packages. 

Contents of Nuget Package

In very simple words, a NuGet package is a single ZIP file with the .nupkg extension that contains compiled code (DLLs), other files related to that code, and a descriptive manifest that includes information like the package’s version number. Library developers create package files and publish them to a host. Package consumers receive those packages, add them to their projects, and then call that library’s functionality in their project code. NuGet itself then handles all of the intermediate details.

A package might be complete in itself or it might also be referring to other packages by for one of its DLL to work. However, you need only concern yourself with those packages that you’re directly using in a project. If any of those packages themselves consume other packages (which can consume packages), NuGet takes care of all those down-level dependencies. This is what makes nuget so much powerful.

Concept of Nuget feeds and Classification

Generally, NuGet packages are stored at a central location and this central location is called as a Feed. A feed can be an external server hosted by NuGet.org or Microsoft. It can also be internal to the team in a network share or a folder in the file system. NuGet packages are consumed through a command line tool that is integrated in Visual Studio or in the NuGet Package Manager, which is a GUI extension to Visual Studio.

Public feeds are accessible to everyone and does not require any authentication to allow consumption of packages. In turn, private feeds requires some kind of authentication mechanism to prove who you are and then only you would be able to consume packages hosted on such feeds. Private feeds may be internal to organization or may be shared between couple or more organizations as well.

Add Package Extension for VSTS

By default, VSTS cannot be used to host Nuget feeds. However, Microsoft has created a extension called ‘Package Management’ to provide this functionality. Just like all other extensions, we need to go to VSTS market place at https://marketplace.visualstudio.com and search for the ‘Package Management’ extension:

Search for Packages Extension and click Get
Search for Packages Extension and click Get

Once you select it, click Get and then Visual Studio will ask it to choose the VSTS account you need to associate it to.

Create a new Nuget Feed

If you had added above mentioned extension successfully, if you go to build and release tab, you would now see a new option named ‘Packages’ from the dropdown:

Packages option inside build and release

This is where to go, if we need to create nuget feeds and then store packages inside those feeds. Since we have not created our first feed yet, if we click it, it will ask us to create our first feed. Provide a name for the feed, select appropriate option and then create:

Provide the name of new feed

You can also change these settings later by editing the feed.

Connect to Package Feed

To connect to feed, first we need to identify the feed options. For that, select ‘Connect to Feed’ right next to feed name:

Connect to Package feed created
Connect to Package feed created

This will load a pop-up window like below:

consume packages in the packages feed
Consume packages from the packages feed

As highlighed in above snap, we can now consume packages using various technologies like Nuget, npm, Maven etc. This also means that Package feeds are not only for Nuget packages, they can also be used to store npm packages, maven packages etc. as well.

5 thoughts on “Configure Visual Studio Team Services (VSTS) to create Nuget feeds

  1. Thank for the article.
    How I could store many nuget packages in a feed?
    I mean to store latest 10 vesrions for example.
    thanks.

    Like

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 )

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s