2
votes

Currently trying to get Team City building a .net solution however I'm running into issues with NuGet package restore.

scan: Searching for nuget.config files

It finds the projects OK, and then attempts to restore the packages from nuget.org.
However after between 5 and 7 attempts (not always on the same one) it fails with a 403 error.
The solution builds fine locally through Visual Studio 2013.

Please note, I'm not using any custom NuGet repos or TFS nor any other deployment tools.

restore: Restoring NuGet packages for XXX.sln
[12:01:58][restore] Installing 'Microsoft.Owin.Host.SystemWeb 1.0.1'.
[12:01:58][restore] The remote server returned an error: (403) Forbidden.

TeamCity server version is 9.0.4 (build 32407)
nuget.exe 2.8.3

This sits behind a corporate firewall/proxy but the fact that it can restore some packages leads me to believe this may not be the route cause of the issue.

1
You need to check the logs of your proxy to see whether the problem is between your TeamCity agent and the proxy, or between the proxy and the NuGet server. If I were a gambling man, I would put money on it being your proxy server being the cause.Paul Turner

1 Answers

0
votes

This happened to me twice in the last week (with two different csproj's).

  1. The first time, I left the issues till the morning, when it just fixed itself. :)
  2. The second time I was not that lucky. So, I went to the build machine, opened the command prompt and ran the command the TeamCity runs (nuget restore MySolution.sln):

    c:\> C:\TeamCity\buildAgent\tools\NuGet.CommandLine.DEFAULT.nupkg\tools\NuGet.exe restore C:\TeamCityCheckOutDir\624ce5421b617487\MySolution.sln
    

    It was able to restore the packages just fine! I then ran the TeamCity build normally and it succeeded. Then, just to make sure, I deleted the hashed folder (624ce5421b617487), re-ran the build and it succeeded again!

Both of these cases make me think about the flakiness of the NuGet as the cause of the issue. Also, when searching for an answer, I seemed to come across suggestions from different other CI vendors to use -DisableParallelProcessing with nuget restore. So, I guess, flakiness = parallel processing? I'll make sure to try to use this flag next time the issue comes up again.

TeamCity server 8.1.4 (build 30168)
nuget.exe 2.8.6