9
votes

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?

3
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
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 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
Here is a similar problem that pointed me into right direction however it doesn't work for private TC NuGet feed: stackoverflow.com/questions/12897747/…mare

3 Answers

17
votes

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.

3
votes

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.

3
votes

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