【问题标题】:Restoring nuget packages of project with the http version of nuget.org using the dotnet cli使用 dotnet cli 使用 nuget.org 的 http 版本恢复项目的 nuget 包
【发布时间】:2017-06-20 08:51:40
【问题描述】:

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

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

【问题讨论】:

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


    【解决方案1】:

    您可以在您的存储库中创建一个NuGet.Config 文件(或使用dotnet new nugetconfig 创建它)并像这样添加提要:

    <?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

    【讨论】:

    • 我照你说的执行了dotnet restore --configfile nuget.config 不幸的是,它似乎仍然使用https。 “对 'GET https://api.nuget.or” 的 HTTP 请求...超时 (x100)
    • 它应该从当前工作目录或以上目录中获取 nuget.config 文件。你可以尝试不同的密钥。修改全局 nuget.config 是否产生相同的结果?
    • 是的,结果相同。我发现了原因:如果你转到 http 版本,响应中的所有链接都是 https,这会导致所有后续请求失败......在这一点上我认为没有一个简单的解决方法。 https 在这个网络上不能完全正常工作是真正的问题......
    • 我将此标记为答案,因为它可以帮助有类似问题的人
    猜你喜欢
    • 2020-06-30
    • 2021-07-17
    • 1970-01-01
    • 2022-10-13
    • 2016-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多