Is it possible to create a cache of nuget packages for computers without internet?

白昼怎懂夜的黑 提交于 2019-12-04 05:05:43

问题


We have a build server, which doesn't have access to internet. It gets our source from a git server, then tries to build them.

Currently, it fails(obviously) because this computer doesn't have internet access. I discussed it with IT, and they agree to let us connect it to internet to do some maintenance, but they refuse to let it connected all the time.

My question is:

Is it possible to create some kind of local nuget cache that we can populate when we do changes on packages, and then the build server will try to use this cache before connecting to the server?


回答1:


I can think of several solutions.

Download packages used by a solution

I answered a very similar question recently, where the person asking wanted to get packages to use on an offline computer. A summary of my answer from the other question is you create a nuget.config that sets the global packages folder to a folder that's currently empty, do a restore, then copy all the .nupkg files to your destination. NuGet supports local folder feeds, so just drop those nupkgs on a network share and tell your build server to use that network share as a nuget source.

An obvious problem is that every time any developer installs a new package (or new version of an existing package), the new packages need to be copied to your local feed.

Mirror nuget.org's packages locally

My team mates have a tool that will use NuGet's v3 catalog api find all non-deleted packages (optionally filtering out unlisted packages) and download all 1.4 to 1.8 million packages locally. Their implementation takes about a week to finish downloading everything. Out interest, I wrote something that used Azure Functions to auto-scale the job and managed to download all the packages in 2 hours. The blob storage account is now 2.4 TiB, so you almost certainly don't want to do this unless you're doing it to analyse the packages on nuget.org, rather than using it as a source to restore packages. You will probably want to periodically update your local feed.

Use a read-though caching server

Since your build server is network connected, work with your IT department to get a read-through caching server. If your company already uses a HTTP proxy, work with your IT department to allow your build server to use it, then configure it as the HTTP proxy.

If your company doesn't have a HTTP proxy, there are several nuget servers you can install in your company. Some of them support read-through caching, so have your IT department set it up in the company DMZ and your build server can use it to get packages from a feed on the internet.



来源:https://stackoverflow.com/questions/53705220/is-it-possible-to-create-a-cache-of-nuget-packages-for-computers-without-interne

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!