How to use AppVeyor Build Cache

Gary Ewan Park
Jul 23, 2017 · 2 min read

Another important feature offered by AppVeyor is it’s Build Cache. Due to the fact that every AppVeyor build uses a fresh copy of the Build Agent Virtual Machine, any files and folders that were created as part of the build are not persisted between project builds.

So for example, if as part of your build you restore lots of NuGet packages, or you install packages from Chocolatey, then these things will have to happen on every build. This is problematic for two reasons.

  1. It means that your builds are going to be slightly slower than they could be as they are having to restore these dependencies on every build
  2. The success of your build is dependent on 3rd party websites being available. So for example, if NuGet.org isn’t working properly, your build is going to fail as those required packages can’t be downloaded.

Making use of the AppVeyor Build Cache fixes both of these problems.

To set up the Build Cache is really simple:

cache: 
- tools -> build.cake, tools/packages.config

With this entry in your .appveyor.yml file, at the end of the build all files and folders within the tools folder will be added to the Build Cache, and restored on the next build. Additionally, if either of the build.cake or tools/packages.config file change between Project Builds, then the tools folder in the Build Cache will be invalidated and re-created during the build.

This configuration gives us full flexibility and control over the Build Cache, which results in a more resilient and re-producible build.

I have created a short video with walks through this entire process, and shows the Build Cache in action, in the context of a build which uses the Cake Build Automation tool.


Originally published at www.gep13.co.uk.

Gary Ewan Park

Written by

Been working with .Net technologies since leaving University in 2004, started out with VB.Net in Visual Studio 2003, and moving onto C# using Visual Studio 2010

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade