One of the things I try to do as part of a build pipeline is to have automatic package updates. My usual pattern is something along the lines of a CI build that runs on every commit and every night, plus a Canary build that updates all the packages to their latest respective versions.

The sequence looks something like this:

  1. The Canary build:
    1. pulls the lastest of the project from the master branch;
    2. runs nuget.exe update or equivalent;
    3. then compiles the code and runs the unit tests.
  2. If everything passes, it does (roughly) this:

     git checkout -b update-packages
     git add -A .
     git commit -m "Automatic package update"
     git push -f origin update-packages
    
     # Note: There's a bit more error-checking around non-merged branches and so on,
     # but that's fundamentally it.
    
  3. The CI build then:
    1. picks up the changes in the update-packages branch;
    2. compiles the code (yes, again), to make sure that we didn’t miss anything in the previous commit);
    3. runs the unit tests;
    4. deploys the package to a CI environment;
    5. runs the integration tests; and
    6. if all is well, merges the update-packages branch back down to master.

For what it’s worth, if a master build is green (and they pretty much all should go green if you’re building your pull requests) then out the door it goes. You do trust your test suite, don’t you? ;)

All of this can be done with stock TeamCity build steps with the exception of one thing: the call to nuget.exe update doesn’t add binding redirects and there’s no way to do that from the console. The Add-BindingRedirect PowerShell command is built into the NuGet extension to Visual Studio and there’s no way to run it from the command line.

That’s always been a bit of a nuisance and I’ve hand-rolled hacky solutions to this several times in the past so I’ve re-written a slightly nicer solution and open-sourced it. You can find the Add-BindingRedirect project on GitHub. Releases are downloadable from the Add-BindingRedirect releases page.

Pull requests are welcome :)