Monthly Archives: July 2014

Restore NuGet Packages for Solution using TeamCity

So you’ve used NuGet packages into your solution and not checked in the packages folder to source control. Visual Studio will download the packages upon build, but TeamCity will not and you will end up with a build error such as:

This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\packages\UmbracoCms.7.1.4\build\UmbracoCms.props.

But, how to enable NuGet Package Restore on TeamCity?

UPDATE: It seems this is as easy as in Visual Studio, right click the solution and Enable Nuget Package Restore for Solution. I’m sure I tried this before and it didn’t work, but it seems to now!

It’s quite easy. Just add a NuGet Installer build step (make sure to order it before the project build step):

 

All I specified is the NuGet version, path to solution file and Restore mode.

The first time you do this no default NuGet version will exist so you have to click NuGet Settings link and Fetch the latest version of NuGet.

Note that after this your build agents will disconnect to install the NuGet version.

Then your build should succeed! Awesome!