Publish to MyGet from a VSTS build
Visual Studio Team Services or VSTS in short allows us to create rich build pipelines. As part of a build, you may want to publish NuGet packages, often including debugger symbols, to your MyGet feed. Let's see how this can be done.
Note: This tutorial describes manually pushing NuGet and/or symbols packages from a VSTS build. The easiest way to publish NuGet package artifacts from VSTS to MyGet is to enable VSTS integration and configure Visual Studio Team Services as an upstream package source.
In this tutorial, we assume NuGet packages are already being created, for example using the NuGet Packager build task. We'll explain the next steps in publishing these packages to your MyGet feed.
Adding the NuGet Publisher build step
Edit your build definition and add a new build step. Under the Package node, find the NuGet Publisher task and add it to your build definition. The order in which this step runs is not very important, except that it has to happen after the NuGet packages already have been created. Ideally, this step only runs when build and running tests is successful.
Configure the NuGet Publisher build step
In the NuGet Publisher build task, make sure the generated packages can be found. The path/pattern will have to be configured correctly (the default usually works fine). The feed type is an External NuGet feed.
Before being able to select the NuGet Server Endpoint, click the Manage button on the right. You will first need to add a new endpoint to the VSTS configuration.
In the toolbar, hit New Service Endpoint | Generic and configure your MyGet feed:
- Connection Name: a description of the feed you will be publishing to.
- Server URL: the package publish URL which can be found in your MyGet feed's "Feed Details" tab. Note that the URL has to end in
/api/v2/packagefor publishing to work succesfully.
- Password/Token Key: the API key to your MyGet feed. This can be found in your MyGet feed's "Feed Details" tab.
Once configured, we can select the NuGet Server Endpoint we just created and save the build step.
Run the build
As part of the build, VSTS will now publish NuGet and/or symbols packages to MyGet.
Note: The blog of Ricci Gian Maria has also a great example of Publishing a Nuget package to Nuget/Myget with VSTS Build vNext>.