Source unreachable when using the NuGet Package Manager Console(使用 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 包管理器控制台时源无法访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 NuGet 包管理器控制台时源无法访问
基础教程推荐
- JSON.NET 中基于属性的类型解析 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
