【问题标题】:dotnet restore looking in wrong nuget-sourcedotnet restore 查找错误的 nuget 源
【发布时间】:2019-12-03 07:42:23
【问题描述】:

我在 Docker 中运行“dotnet restore” 我的 Nuget.Config 的相关部分如下所示

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

来自我的 Dockerfile

COPY ["NuGet.Config", "myproject.Api/"]
RUN dotnet restore "myproject.Api/myproject.Api.csproj" --configfile nuget.config

其中一个包是我从 nuget.org 获得的“MassTransit”,但还原操作给了我错误

无法从以下位置下载包“MassTransit.5.5.6” 'https://mycompanysource.com/.../nuget/v3/flat2/masstransit/5.5.6/masstransit.5.5.6.nupkg'。

出于某种原因,私人来源拥有 MassTransit (5.5.5),所以我认为这使事情变得混乱。 我能否以某种方式强制 nuget 使用 MassTransit 的特定来源?(我需要 nuget.org 和私有 nuget 存储库)

【问题讨论】:

    标签: docker .net-core nuget


    【解决方案1】:

    在与您概述的问题非常相似的问题上反复试验后,我找到了一个潜在的解决方法。由于 NuGet 中的设计决策,如果任何源无法在您的依赖关系图中进行身份验证,您的其他包可能无法下载。在用私有源更正我们的身份验证问题后,公共包成功恢复。

    您的私人 (https://mynugetsource.com/nuget/v3/index.json) 来源是否收到身份验证错误?

    相关:https://github.com/NuGet/Home/issues/6373

    【讨论】:

    • 尝试在 dockerfile 中运行 DOTNET RESTORE 时遇到相同的错误。但是当我在项目目录中运行它时,它执行正常。我没有遇到身份验证错误
    猜你喜欢
    • 2018-02-04
    • 1970-01-01
    • 2019-03-17
    • 1970-01-01
    • 1970-01-01
    • 2021-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多