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 包管理器控制台时源无法访问


- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- 输入按键事件处理程序 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01