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:
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:
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:
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:
This will load a pop-up window like below:
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.
6 thoughts on “Configure Visual Studio Team Services (VSTS) to create Nuget feeds”
Will you be able to host Powershell modules via this feed (like Powershell gallery currently)?
Thank for the article.
How I could store many nuget packages in a feed?
I mean to store latest 10 vesrions for example.
Hi, you need to specify feed name or id during the upload time. Also, you can store as many packages and their versions as you need.
Thank you, Mohit, I found where all versions are stored. They are under the tab Versions inside the package.
[…] long since I have written blog post about using Nuget Package feeds in VSTS, which can be found here. I have always wanted to write a follow up blog post about how to use feeds further but I was […]