Using TeamCity to enable NuGet package restore for solution-level packages


What’s a solution-level package?

A solution-level package is one that installs a tool or additional commands for the Package Manager console, but does not add references or content to any projects in your solution. For example, the psake package installs PowerShell scripts you can use to automate your build process.

A package is considered a solution-level package if it does not contain any files in its lib or content directories. If the package has dependencies, they also must not have files in their lib or content directories.

When a solution-level package is installed, it is tracked in a packages.config file in the .nuget directory, rather than in a packages.config file in a specific project.

NuGet package restore which is often used when you don’t want to check-in the “packages” folder doesn’t really support package restore, it’s actually by-design as per this statement:

We have the limitation that build cannot restore solution packages. But through VS you can use the button to restore, and from the command line you can run nuget.exe install from the .nuget folder.


It works from Visual Studio…yes!

But on the build server…there’s no Visual Studio and fancy buttons to press so we have to use nuget.exe instead, let’s see how!


As the title of this blog post hints we’re using the power of TeamCity to enable, or overcome the by-design issues of NuGet, package restore for solution packages.
However you could apply this “fix” in any situation (or build server) where you can run an executable. TeamCity just makes it pretty easy.

Given that you have your .nuget folder (nuget.exe, packages.config at least) in source control all you have to-do is this:


  1. Add a new build step (Command-Line)
  2. Set the working directory to the .nuget folder
  3. Run nuget.exe
  4. With these parameters:
    install packages.config –o ..\packages
    note: -o ..\packages is the path where the output should be placed (the packages folder is usually a good place)

After you’ve created the new build step you need to put it first (or at least before your compile step) as the following image shows.


Be Happy!

Update 2013-06-17

You can also use the technique used in this post.



  1. #1 by Biju on July 11, 2013 - 12:35

    I am getting the error “The remote name could not be resolved: ‘”

    • #2 by Johan Leino on July 11, 2013 - 15:23

      It’s probably because your server can’t connect to the Internet…

  2. #3 by Suneeth on October 25, 2013 - 17:25

    am getting the same error as Biju “The remote name could not be resolved: ‘” and i tried to access on IE on the server.

  3. #4 by Ievgen on September 11, 2014 - 15:56

    The remote name could not be resolved: ‘” – the same for me! ((((

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: