Why is my NuGet client failing to download packages?

Why is my NuGet client failing to download packages?

AuthorFullName__c
JFrog Support
articleNumber
000001289
ft:sourceType
Salesforce
FirstPublishedDate
2016-10-06T13:38:09Z
lastModifiedDate
2024-03-10T07:49:12Z
VersionNumber
6

If you fail to download (cache) from nuget remote repository (e.g. nuget gallery), check the request.log to see if a request for the nuget package was sent authenticated with a user that has valid permission.

If indeed the request was sent with valid credentials, and the user had all the needed permissions to cache the remote artifact, the issue could be related to proxy settings.

When trying to download nuget package from nuget gallery, the nuget gallery redirects to another download server, so the proxy must allow the download from the redirected URL.

To make sure that the problem is not in Artifactory side, try to download the requested package directly from nuget gallery through the proxy from the Artifactory machine. This way, you will be able to identify if it is a proxy issue or not.

For example, you can run the following command (with changing the proxy details) from the Artifactory machine and see what the result is:

curl -fv -x http://user:password@proxyhost:proxyport "http://www.nuget.org/api/v2/package/CKEditor/3.6.4" -L > file.pkg

* About to connect() to proxy localhost port 8888 (#0)

*   Trying 127.0.0.1...

 % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

                                Dload  Upload   Total   Spent    Left  Speed

 0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* Connected to localhost (127.0.0.1) port 8888 (#0)

> GET http://www.nuget.org/api/v2/package/CKEditor/3.6.4 HTTP/1.1

> User-Agent: curl/7.29.0

> Host: www.nuget.org

> Accept: */*

> Proxy-Connection: Keep-Alive

>

< HTTP/1.1 302 Found

< Cache-Control: private

< Content-Type: text/html; charset=utf-8

< Location: http://az320820.vo.msecnd.net/packages/ckeditor.3.6.4.nupkg

< Server: Microsoft-IIS/8.0

< X-AspNetMvc-Version: 4.0

< X-AspNet-Version: 4.0.30319

< X-Powered-By: ASP.NET

< X-Frame-Options: deny

< X-XSS-Protection: 1; mode=block

< X-Content-Type-Options: nosniff

< Strict-Transport-Security: maxage=31536000; includeSubDomains

< Date: Thu, 25 Sep 2014 21:41:24 GMT

< Content-Length: 176

< Proxy-Connection: Keep-alive

<

* Ignoring the response-body

{ [data not shown]

100   176  100   176    0     0    788      0 --:--:-- --:--:-- --:--:--   792

* Connection #0 to host localhost left intact

* Issue another request to this URL: 'http://az320820.vo.msecnd.net/packages/ckeditor.3.6.4.nupkg'

* About to connect() to proxy localhost port 8888 (#1)

*   Trying 127.0.0.1...

* Connected to localhost (127.0.0.1) port 8888 (#1)

> GET http://az320820.vo.msecnd.net/packages/ckeditor.3.6.4.nupkg HTTP/1.1

> User-Agent: curl/7.29.0

> Host: az320820.vo.msecnd.net

> Accept: */*

> Proxy-Connection: Keep-Alive

>

< HTTP/1.1 200 OK

< Accept-Ranges: bytes

< Content-Type: application/zip

< Date: Thu, 25 Sep 2014 21:41:25 GMT

< Etag: 0x8CFE8D69FC5DD93

< Last-Modified: Wed, 06 Mar 2013 23:08:18 GMT

< Server: ECAcc (rhv/811F)

< X-Cache: HIT

< x-ms-blob-type: BlockBlob

< x-ms-lease-status: unlocked

< x-ms-request-id: ec05a099-0001-0073-110b-5c576a000000

< x-ms-version: 2009-09-19

< Content-Length: 1066902

< Proxy-Connection: Keep-alive

<

{ [data not shown]

100 1041k  100 1041k    0     0  1170k      0 --:--:-- --:--:-- --:--:-- 1170k

* Connection #1 to host localhost left intact

As you can see, in the above example, the nuget server redirects the request to another download server and the client follows the redirection and downloads the file.  This is also reflected in the NuGet documentation.

When there is a problem with the proxy, you will see a different status than the HTTP 200.