使用 NuGet 包管理器控制台时源无法访问 [英] Source unreachable when using the NuGet Package Manager Console

查看:26
本文介绍了使用 NuGet 包管理器控制台时源无法访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在将包管理从手动更新文件转移到 NuGet.我正在尝试安装旧版本的软件包以匹配我们在源代码管理中已有的软件包.无法从 UI 中执行此操作,因此我使用命令行来获取正确的版本.

We are moving our package management from manually updating files to NuGet. I am trying to install older versions of packages to match the one we already have in source control. There is no way to do this from the UI so I use the command line to get the proper version.

出于某种原因,Install-Package 不断告诉我 nuget 库无法访问.

For some reason, Install-Package keeps on telling me that the nuget gallery is unreachable.

nuget.org 上的来源 [https://www.nuget.org/api/v2/] 无法访问.回退到 NuGet 本地缓存

The source at nuget.org [https://www.nuget.org/api/v2/] is unreachable. Falling back to NuGet Local Cache

这只发生在我们的一种解决方案中.如果我在同一个存储库中创建一个新解决方案或使用另一个解决方案,包将按预期安装.我什至可以将软件包安装在虚拟解决方案中以填充本地缓存,然后将它们成功安装到错误的解决方案中.我尝试在 NuGet 控制台的 url 上 Invoke-WebRequest 并得到 HTTP 200.

This happens only in one of our solutions. If I create a new solution or use another one in the same repository, packages will install as expected. I can even install the packages in a dummy solution to fill the local cache and then install them successfully in the faulty solution. I have tried to Invoke-WebRequest on the url from the NuGet Console and I get an HTTP 200.

是什么原因造成的?有没有办法在每个解决方案/项目的基础上覆盖包源?

What can cause this? Is there a way to override the package sources on a per solution/project basis?

推荐答案

尽管我的 Package Source 在包管理器控制台中设置为 nuget.org,但显式添加了 -Source nuget.org 参数为我解决了这个问题.

Even though my Package Source was set to nuget.org in Package Manager Console, explicitly adding the -Source nuget.org argument fixed this for me.

所以一个使用的例子是:

So an example of use would be:

Install-Package Akka.net -Source nuget.org

Akka.net 是您要安装的软件包,这里只是一个示例.

Akka.net being your package that you want to install, its just an example here.

这篇关于使用 NuGet 包管理器控制台时源无法访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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