.net - 使用 dotnet cli 通过 http 版本的 nuget.org 恢复项目的 nuget 包

标签 .net nuget nuget-package-restore dotnet-cli

我正在尝试 dotnet Restore 我的 .net core 项目,但是我无法从当前工作站访问 https://api.nuget.org/* (所以命令只是超时),但是可以访问 http://api.nuget.org/*。

有没有办法让 dotnet cli 使用 http 版本的 nuget.org?

最佳答案

您可以在存储库中创建一个 NuGet.Config 文件(或使用 dotnet new nugetconfig 创建它),并添加如下 Feed:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
 <packageSources>
    <clear />
    <add key="nuget.org" value="http://api.nuget.org/v3/index.json" protocolVersion="3" />
 </packageSources>
</configuration>

您还可以更新全局 NuGet.Config 文件以进行匹配。它位于 *nix 上的 ~/.nuget/NuGet/NuGet.Config 和 Windows 上的 %APPDATA%\NuGet\NuGet.Config

关于.net - 使用 dotnet cli 通过 http 版本的 nuget.org 恢复项目的 nuget 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44648237/

相关文章:

未安装 Nuget 依赖项

jenkins - 在命令行中构建 UWP 应用程序(使用 MSBUILD)

c# - NuGet 找不到现有包

c# - react 性扩展 : Stop an observable from returning before the tasks it has spun off have finished?

c# - "legacy".NET 项目是否也可以使用新的 NuGet 3 功能?

c++ - GetAsyncKeyState(VK_RETURN) 错误地评估为真

c# - System.EntryPointNotFoundException + 无法安装包 'SQLite.Interop.dll 1.0.103' 。我的项目目标'.NETFramework,Version=v4.6.1'

azure-devops - 如何删除 [警告] 在还原 NuGet 包时连接到 NuGet 源

c# - 无法使用 Select.Pdf 中的 HTML 到 PDF 转换器获取粗体文本

c# - 区分 XElement 中的 null 和 string.Empty 值