docker - 从私有(private) nuget 源恢复 nuget 包 - Docker 给出错误

标签 docker asp.net-core

我正在尝试构建一个 docker 镜像,但在尝试从私有(private) Nuget Feed 恢复 Nuget 包时出现此错误。我已经尝试了来自互联网各地的许多解决方案。到目前为止没有任何工作。请帮助。

我的 Docker 文件如下所示: -

FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-stretch-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/core/sdk:2.2-stretch AS build
WORKDIR /src
COPY ["Api/Api.csproj", "Api/"]
COPY ["Persistence.EntityFramework/Nuget.config", "Persistence.EntityFramework/"]
COPY ["Contracts/Contracts.csproj", "Contracts/"]
COPY ["Persistence/Persistence.csproj", "Persistence/"]
COPY ["Domain/Domain.csproj", "Domain/"]
COPY ["Handlers/Handlers.csproj", "Handlers/"]
COPY ["Localisation/Localisation.csproj", "Localisation/"]
COPY ["Persistence.EntityFramework/Persistence.EntityFramework.csproj", "Persistence.EntityFramework/"]
RUN dotnet restore "Persistence.EntityFramework/Persistence.EntityFramework.csproj" --configfile "Persistence.EntityFramework/Nuget.config"
RUN dotnet restore "Api/Api.csproj"
COPY . .
WORKDIR "/src/Api"
RUN dotnet build "Api.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "Api.csproj" -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "Security.Api.dll"]

我的 Nuget.Config 看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageRestore>
    <!-- Allow NuGet to download missing packages -->
    <add key="enabled" value="True" />
    <!-- Automatically check for missing packages during build in Visual Studio -->
    <add key="automatic" value="True" />
  </packageRestore>
  <packageSources>
    <add key="NuGet.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    <add key="companyname" value="http://vnuget.companyname.com/privateNugetFeed/nuget/Packages"/>    
  </packageSources>
</configuration>

这是我们看到的错误:
Retrying 'FindPackagesByIdAsyncCore' for source 'http://vnuget.companyname.com/privateNugetFeed/nuget/Packages/FindPackagesById()?id='Microsoft.EntityFrameworkCore.Relational'&semVerLevel=2.0.0'.
[15:44:36][Step 3/7]   Response status code does not indicate success: 400 (Bad Request).

最佳答案

嗨,我发现了问题..

我的 Nuget 配置文件中的包源链接不正确

它应该是 :-

 <add key="companyname" value="http://vnuget.companyname.com/privateNugetFeed/nuget"/>  

这已经解决了这个问题,docker 正在正确构建!瞧

关于docker - 从私有(private) nuget 源恢复 nuget 包 - Docker 给出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57311788/

相关文章:

docker - Teradata 数据库 Docker 镜像

node.js - 通过 API 网关安全路由的 ECS 容器未返回,但对容器的健康检查良好

linux - LXC:是来自linuxcontainers.org还是Linux内核的一部分?

c# - 在 .NET Core 2 Web Api 中验证 JWT 后获取用户数据的最佳实践是什么?

.net - Restsharp 在服务器上运行时引发 SSL 错误

c# - 如何根据所需的类注册依赖项(使用 ASP CORE 中的内置 IOC 容器)

mysql - 为 Dockerized Django 应用程序播种 MySQL 数据库

java - 无法从 Java 连接到在 Docker 中运行的 Kafka

asp.net - ef核心迁移插入数据

c# - 将 .NET Framework 4.5 dll 添加到 .NET Core 项目