9

I receive the following error in NuGet Install build step when setting sources to TeamCity's NuGet server:

Step 1/4: NuGet install (NuGet Installer) (3s)

[15:11:19][Step 1/4] scan: Searching for nuget.config files

[15:11:19][Step 1/4] install: Installing NuGet packages for packages.config (3s)

[15:11:19][install] NuGet command: C:\TeamCity\buildAgent\tools\NuGet.CommandLine.2.2.0.nupkg\tools\NuGet.exe install C:\TeamCity\buildAgent\work\a4b9de5be22a981\packages.config -OutputDirectory C:\TeamCity\buildAgent\work\a4b9de5be22a981\packages -Source http://localhost:9090/guestAuth/app/nuget/v1/FeedService.svc

[15:11:19][install] Starting: C:\TeamCity\buildAgent\temp\agentTmp\custom_script96367186180319830.cmd

[15:11:19][install] in directory: C:\TeamCity\buildAgent\work\a4b9de5be22a981

[15:11:22][install] The remote server returned an error: (404) Not Found.

[15:11:22][install] Process exited with code 1

[15:11:22][Step 1/4] Step NuGet install (NuGet Installer) failed

If I leave sources field blank, it will find the NuGet packages from the default feed (NuGet community feed) but not the ones that are built and packaged locally and hosted within TC's NuGet feed.

How do you use both the default feed and the internal TC's NuGet feed within the NuGet installer build step?

mare
  • 13,033
  • 24
  • 102
  • 191
  • Did you try putting both the Team City NuGet feed url and the standard NuGet feed url in the build step as package sources? The NuGet.exe command line looks like it is only using one package source. I would also check the Team City NuGet feed url is correct and guest auth is switched on since I do not think it should return a 404. NuGet.exe should return a message indicating the package was not found and not a 404. – Matt Ward Jan 01 '13 at 17:50
  • The 404 happens because when using %teamcity.nuget.feed.server% in the Package sources field this gets translated into the guest (no auth) TC's NuGet feed (which is something like http://localhost:9090/guestAuth/app/nuget/v1/FeedService.svc). However, I have the public feed disabled. That is why 404. I figured thar out just now. Still researching on how to do this with private feed and am yet to find a solution. – mare Jan 01 '13 at 21:52
  • Here is a similar problem that pointed me into right direction however it doesn't work for private TC NuGet feed: http://stackoverflow.com/questions/12897747/how-should-i-tell-teamcitys-nuget-installer-build-step-to-use-both-nuget-org-an – mare Jan 01 '13 at 21:55

3 Answers3

17

You can specify custom feeds just for solution via nuget.config file.

The key point is to provide credentials section packageSourceCredentials like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="Local" value="http://localhost:9090/httpAuth/app/nuget/v1/FeedService.svc" />
  </packageSources>
  <activePackageSource>
    <add key="Local" value="http://localhost:9090/httpAuth/app/nuget/v1/FeedService.svc" />
  </activePackageSource>
  <packageSourceCredentials>
    <Local>
      <Username>login</Username>
      <Password>pa$$w0rd</Password>
    </Local>
  </packageSourceCredentials>
</configuration>

This config file should be next to the sln file in repository.

Aleš Roubíček
  • 5,198
  • 27
  • 29
  • 1
    This solution is definitely easy but it leaves your repository password source control. This is generally considered a [security risk](http://stackoverflow.com/questions/559611/password-storage-in-source-control). – John Hoerr Feb 04 '13 at 17:08
  • This solution worked even if the credentials are not provided and packages are on a network repository. – Shriroop Feb 11 '15 at 18:01
3

This appears to be a known issue for TeamCity. The workaround suggests adding the package source via the command line client and then updating those sources with the authorization credentials:

nuget sources add -name [name] -source [feedUrl]
nuget sources update -Name [name] -User [username] -pass [password]

It's my understanding that Nuget will cache those credentials for future requests. I don't know how often that cache is cleared; you may need to run that nget sources update right before you kick off your build to ensure that the cache is coherent.

John Hoerr
  • 7,955
  • 2
  • 30
  • 40
  • They get added to the users nuget.config. Eg: C:\users\john\appdata\nuget\nuget.config They dont expire – Sam Feb 25 '13 at 05:28
3

We implemented authenticated feed support in TeamCity plugin. Please follow comments to the issue http://youtrack.jetbrains.com/issue/TW-20764

Eugene Petrenko
  • 4,874
  • 27
  • 36