是否可以为没有互联网的计算机创建 nuget 包的缓存? [英] Is it possible to create a cache of nuget packages for computers without internet?

查看:48
本文介绍了是否可以为没有互联网的计算机创建 nuget 包的缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个无法访问互联网的构建服务器.它从 git 服务器获取我们的源代码,然后尝试构建它们.

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.

目前,它失败(显然)是因为这台计算机无法访问互联网.我和 IT 商量过了,他们同意让我们把它连接到互联网做一些维护,但他们拒绝让它一直连接.

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.

我的问题是:

是否可以创建某种本地 nuget 缓存,当我们对包进行更改时可以填充该缓存,然后构建服务器将在连接到服务器之前尝试使用该缓存?

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?

推荐答案

我能想到几个解决方案.

I can think of several solutions.

最近回答了一个非常相似的问题,提出问题的人想要在离线计算机上使用软件包.我对另一个问题的回答总结是您创建了一个 nuget.config,将全局包文件夹设置为当前为空的文件夹,进行还原,然后将所有 .nupkg 文件复制到您的目的地.NuGet 支持本地文件夹提要,因此只需将这些 nupkg 放在网络共享上,并告诉您的构建服务器将该网络共享用作 nuget 源.

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.

我的队友有一个工具可以使用 NuGet 的 v3 目录 api 找到所有未删除的包(可选择过滤掉未列出的包)并在本地下载所有 1.4 到 180 万个包.他们的实施需要大约一周的时间才能完成下载所有内容.出于兴趣,我写了一些使用 Azure Functions 自动扩展作业并设法在 2 小时内下载所有包的东西.blob 存储帐户现在是 2.4 TiB,因此您几乎肯定不想这样做,除非您这样做是为了分析 nuget.org 上的包,而不是将其用作还原包的源.您可能希望定期更新您的本地供稿.

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.

由于您的构建服务器已连接网络,因此请与您的 IT 部门合作以获取通读缓存服务器.如果您的公司已经使用 HTTP 代理,请与您的 IT 部门合作,允许您的构建服务器使用它,然后将其配置为 HTTP 代理.

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.

如果您的公司没有 HTTP 代理,则有几个 nuget 服务器 您可以在您的公司中安装.其中一些支持通读缓存,因此让您的 IT 部门在公司 DMZ 中设置它,您的构建服务器可以使用它从 Internet 上的提要获取包.

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.

这篇关于是否可以为没有互联网的计算机创建 nuget 包的缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆