NuGet Proxy Repositories
The NuGet Gallery is the common repository used by all package authors and consumers. To reduce duplicate downloads and improve download speeds for your developers and CI servers, you should proxy the NuGet Gallery with the repository manager. If you use other external repositories, you should also proxy these. A default installation of the repository manager has the NuGet gallery set up as a proxy repository with the name nuget.org-proxy.
To proxy another external NuGet repository, you simply create a new nuget (proxy) as documented in Repository Management. The Remote Storage has to be set to the URL of the remote repository you want to proxy. The default configuration for proxying the NuGet Gallery is partially visible in Figure: “NuGet Proxy Repository Configuration for the NuGet Gallery” and uses the URL of the API
Figure: NuGet Proxy Repository Configuration for the NuGet Gallery
By default, searches in NuGet proxy repositories in the repository manager initiated by a client like
nuget or VisualStudio will be passed through to the remote repositories. The search results are merged with internal search results and included in an internally managed index. This merging has to make some assumptions to generate component counts. These counts should therefore be considered approximate numbers. The cache can be configured in the NuGet section documented in NuGet Repository Format.
Once complete the V3 entry point for the proxy repository becomes:
http://localhost:8081/repository/nuget-proxy-v3/index.json). This is the package source that should be passed to the nuget client in order to work with packages.
Read more about the API at https://docs.microsoft.com/en-us/nuget/api/overview. NuGet.org has updated its package service to version 3 which provides significant performance improvements over its legacy version 2 (OData-based) service. The V2 endpoint (
http://www.nuget.org/api/v2/ is still supported but not recommended. To use this or any V2 endpoint, you can use the NuGet V2 entry in the Protocol version field.
Failure to use the correct NXRM URL or incorrect NuGet version protocol will cause the repository to process requests using the V2 API. If the Remote Storage is pointing to a V3 Service Index this will provide no results for package requests and potentially cause build errors.
$ nuget list packageid:newtonsoft.json -Source http://localhost:8081/repository/nuget-proxy-v3/index.json Newtonsoft.Json 12.0.3 $ nuget install newtonsoft.json -Source http://localhost:8081/repository/nuget-proxy-v3/index.json Feeds used: http://localhost:8081/repository/nuget-proxy-v3/index.json Installing package 'newtonsoft.json' to '/workspace/nuget'. CACHE http://localhost:8081/repository/nuget-proxy-v3/v3/registration/5/newtonsoft.json/index.json Attempting to gather dependency information for package 'newtonsoft.json.12.0.3' with respect to project '/workspace/nuget', targeting 'Any,Version=v0.0' Gathering dependency information took 19.78 ms Attempting to resolve dependencies for package 'newtonsoft.json.12.0.3' with DependencyBehavior 'Lowest' Resolving dependency information took 0 ms Resolving actions to install package 'newtonsoft.json.12.0.3' Resolved actions to install package 'newtonsoft.json.12.0.3' Retrieving package 'Newtonsoft.Json 12.0.3' from 'http://localhost:8081/repository/nuget-proxy-v3/index.json'. GET http://localhost:8081/repository/nuget-proxy-v3/v3/content/0/newtonsoft.json/12.0.3/newtonsoft.json.12.0.3.nupkg OK http://localhost:8081/repository/nuget-proxy-v3/v3/content/0/newtonsoft.json/12.0.3/newtonsoft.json.12.0.3.nupkg 567ms Installing Newtonsoft.Json 12.0.3. Adding package 'Newtonsoft.Json.12.0.3' to folder '/workspace/nuget' Added package 'Newtonsoft.Json.12.0.3' to folder '/workspace/nuget' Successfully installed 'Newtonsoft.Json 12.0.3' to /workspace/nuget Executing nuget actions took 935.87 ms