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

3

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?

Practise answered 31/12, 2012 at 14:23 Comment(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.Doglike
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.Practise
Here is a similar problem that pointed me into right direction however it doesn't work for private TC NuGet feed: #12898247Practise
K
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.

Kowatch answered 2/1, 2013 at 17:51 Comment(2)
This solution is definitely easy but it leaves your repository password source control. This is generally considered a security risk.Towhee
This solution worked even if the credentials are not provided and packages are on a network repository.Schaffel
T
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.

Towhee answered 2/1, 2013 at 18:2 Comment(1)
They get added to the users nuget.config. Eg: C:\users\john\appdata\nuget\nuget.config They dont expireAggressor
B
3

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

Bourke answered 11/1, 2013 at 8:29 Comment(1)
6 years later and TeamCity still doesn't support authenticated NuGet feeds? Or am I missing something?Lung

© 2022 - 2024 — McMap. All rights reserved.