Stumbled on a little gotcha today when using nuget packages as deployment artifacts to be send to Octopus Deploy and thought it worth documenting so i don't forget next time.

The quick answer is that you cannot push the same package and version to the built in octopus deploy package repository - if you try you get 400 (Bad Request).

Our build process goes a little like this:

  • Install the Octopack nuget package in each deployable project in the solution
  • Compile the solution using Teamcity and msbuild, specifying the octopack build property to output packages msbuild MySolution.sln /t:Build /p:RunOctoPack=true
  • Use a teamcity nuget publish build step to push the package from the teamcity artifacts into the built in Octopus package repository
  • Create and deploy the release in Octopus

However when I ran the publish step I would get an error in the Teamcity logs and the publish would fail. Octopus was returning a 400 Bad Request status to nuget.exe.

So I tried to push the package manually from the command line like below and got the same error:

It took me a while to realise this was actually by design - an earlier build had already pushed that exact package and version and so I could not overwrite it. The trick to avoiding that in future was to have the compile/version/publish steps all in one Teamcity build (rather than sequential builds) so that you could never push the same build number twice.