migrating an OSS project from MyGet to AppVeyor

When I was first searching around for the easiest (free) automated build & deploy process for my first OSS project, Obvs, the internet directed me to MyGet. As well as hosting NuGet feeds for you, they also have a Build Services feature. Out of the box it did everything I needed, with sensible defaults, and I was building and deploying to NuGet.org in no time.

Oh No, MyGet Build Error

As MyGet’s Build Service still in Preview, it’s reasonable to expect that things may become unstable, and after I recently committed a small change my build failed unexpectedly. Upon further investigation it seemed their new test runner, Gallio, was throwing an exception when trying to run my NUnit tests.

myget-build-error

Their support staff replied almost immediately by email (amazing for a free service) and confirmed that Gallio doesn’t support NUnit, and directed me to a simple workaround of using a custom testrunner.

Introducing AppVeyor

Instead I decided to take this opportunity to try out AppVeyor, another fantastic CI service which is free for public repositories, with a wonderfully clean and simple web interface. Below are some simple steps I went through to recreate the build/package/deploy steps I had in MyGet.

How to add a new NuGet project to AppVeyor

  1. Login with GitHub
  2. Add Project > select repository from GitHub
  3. Edit Project Settings > General
  4. Change build version format to 1.0.0.{build}, where {build} auto-increments on each build
  5. Turn AssemblyInfo Patching from OFF to ON, this will find/replace strings in AssemblyInfo.cs
  6. Remember to click Save before editing next section otherwise you lose your changes
  7. Edit Project Settings > Build
  8. Enter ‘Release’ in the Configuration section, unless you want to use your Project Default
  9. Check the option ‘Package NuGet projects’
  10. Click CMD button on ‘Before build script’ and enter ‘nuget restore’
  11. Remember to click Save
  12. Browse back to your Project > Latest Builds and hit New Build

What should happen next

  1. Build queued for a few minutes, in which time you can Cancel if you forgot something
  2. Then you get a nice scrolling command line view of your build
  3. Clones your git repo
  4. Patches your AssemblyInfo.cs file with the {version}
  5. Restores your NuGet packages
  6. Builds your solution
  7. Finds your .csproj file, calls nuget pack, which should find your corresponding .nuspec file, and substitute the version from your patched assembly version
  8. Runs your tests
  9. Uploads your .nupkg artifacts
  10. Success!

Deploying to NuGet

  1. Create a new Deployment Environment
  2. Select NuGet as the Provider
  3. Give your environment a name, e.g. NuGet.org
  4. Enter your secret API key, which you can get from logging into your NuGet.org account and copying it from there
  5. Click Add Environment

Now you can browse to your Environment tab and you are presented with a really clean and simple overview of the deployment status of all your projects in that environment, and from there you can simply click Deploy to deploy your brand new nupkg to NuGet.

appveyor-deploy-nuget

And that’s it. There are a lot of other options to play with, but I was very happy to discover all the features I’d come to rely on in MyGet were also present in AppVeyor.

It’s really amazing that we actually have a choice of such fantastic free services, but I have to say I much prefer AppVeyor’s simple UI, and of course their support of NUnit out of the box, so I will stick with them for now.

 

Leave a Reply