How to add the custom nuget feed to TeamCity build?

Eugene picture Eugene · Jan 27, 2013 · Viewed 22.9k times · Source

I have created a Nuget Server using Teamcity (running on a virtual machine in internet) and created the build that publishes a package into it.

I also have another project that needs to use that package. This project is built on teamcity as well. On my local Visual Studio I added the nuget feed uri, installed the package and everything works fine. But when I try to build it on teamcity it says that "Package not found".

So my question is : "How to add the custom nuget feed to TeamCity build?"

Answer

John Hoerr picture John Hoerr · Jan 27, 2013

The NuGet package sources are configured through Visual Studio, but they're stored in a per-user configuration file, found at c:\Users\$USER\AppData\Roaming\NuGet\NuGet.config. The entry for the TeamCity package source needs to be added to the config file of the build agent user that's running your builds.

  1. On your local machine, open the Nuget.config file for your user
  2. Copy the entry for the TeamCity package source to the clipboard
  3. On the build agent, open the NuGet.config file for the user that's executing your TeamCity builds
  4. Paste in the TeamCity package source entry. Save & quit.
  5. Run the build again. It should now be able to find the package.

EDIT: ladenedge documents a good solution that didn't exist when I originally answered this question. The solution is especially useful if you don't have admin access to the build agent or want to configure package sources on a per-project basis.