我正在尝试构建一个 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/