TeamCity Nuget install build step not working with multiple sources, one of them TC's private NuGet feed

StackOverflow https://stackoverflow.com/questions/14102695

  •  13-12-2021
  •  | 
  •  

Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top