Continuously publishing Nuget package to MyGet using VSTS

Step 1 - Create your NuGet feed using MyGet

I use MyGet to publish my package for CI. The service is free as long as you don't exceed 500MB and it allows me to not polute NuGet.org with lots of in-development packages. Plus, the 500MB limits is very high and you can configure retention rules to automatically delete old package versions.

Go to https://www.myget.org to create your first feed. Once you complete the steps, you should get this screen:

The 1 is the url to push packages. The 2 is the key to publish packages. You'll need these information later to configure the build task.

Step 2 - Create the VSTS build

  1. Create service

To configure the NuGet Publisher task, you must add the MyGet endpoint. Go in the project settings, select "Services", and add a generic service endpoint with the URL of the MyGet feed (number 1 in the previous screenshot).

  1. Add NuGet Packager task. Select an automatic versionning mode, so every build generate a unique package version.

  1. Add NuGet Publisher task. Select the server endpoing and add the API Key.

  1. Configure the build to run after each checkin

You can now run a build and see the package on MyGet.

Step 3 - Configure Visual Studio to use the MyGet feed

You need to configure the NuGet client to use the MyGet feed in Visual Studio.

  1. Create a NuGet.config file at the root folder of your solution.
  2. Add the NuGet V3 feed URL
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="MyGet feed" value="https://www.myget.org/F/meziantou-sample/api/v3/index.json" />
  </packageSources>
</configuration>
  1. Restart Visual Studio

Conclusion

In about 5 minutes, you can configure VSTS to deploy your NuGet packages to MyGet after every checkin 😃

Enjoy this blog? Buy Me A Coffee Donate with PayPal

Comments

Leave a reply