Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
292 views
in Technique[技术] by (71.8m points)

Error NU1605: Docker restore nuget packages failed

I am running my .netcore3.1 microservices into docker, for this I have added docker(window based) file into service. When I run microservice with docker its throw error on step 'determining projects to restore...'

error

warning NU1603: Team.Api depends on ExceptionHandler (>= 1.0.0-CI-20200424-092531) but ExceptionHandler 1.0.0-CI-20200424-092531 was not found. An approximate best match of ExceptionHandler 1.0.0 was resolved.
    1>/src/TeamApi/Team.Api.csproj : warning NU1603: Team.Api depends on MessageBroker (>= 1.0.0-CI-20200923-130139) but MessageBroker 1.0.0-CI-20200923-130139 was not found. An approximate best match of MessageBroker 1.0.0 was resolved.
    1>/src/TeamApi/Team.Api.csproj : error NU1101: Unable to find package MessageBrokerRabbitMQ. No packages exist with this id in source(s): nuget.org
    1>/src/TeamApi/Team.Api.csproj : warning NU1701: Package 'ExceptionHandler 1.0.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETCoreApp,Version=v3.1'. This package may not be fully compatible with your project.
    1>/src/TeamApi/Team.Api.csproj : error NU1605:  Team.Api -> MessageBroker 1.0.0 -> Microsoft.Extensions.Hosting 3.1.3 -> Microsoft.Extensions.Logging.Debug (>= 3.1.3)
    1>/src/TeamApi/Team.Api.csproj : error NU1605: Detected package downgrade: Microsoft.Extensions.Logging.Debug from 3.1.3 to 3.1.1. Reference the package directly from the project to select a different version.
    1>/src/TeamApi/Team.Api.csproj : error NU1605:  Team.Api -> Microsoft.Extensions.Logging.Debug (>= 3.1.1)
    1>  Failed to restore /src/TeamApi/Team.Api.csproj (in 52.24 sec).

docker throw error on randomly package on every build

Docker specs which I am using are:

Windows version: 1903 (18362.418)
Docker Desktiop version: 3.1.0 (51484)
Engine: 20.10.2

Docker file created by Visual Studio 2019

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /src
COPY ["TeamApi/Team.Api.csproj", "TeamApi/"]
RUN dotnet restore "TeamApi/Team.Api.csproj"
COPY . .
WORKDIR "/src/TeamApi"
RUN dotnet build "Team.Api.csproj" -c Release -o /app/build

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

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

I have created docker file for Linux as well but the result is same

Update1: Project's .csproj file

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup Label="Globals">
    <SccProjectName>SAK</SccProjectName>
    <SccProvider>SAK</SccProvider>
    <SccAuxPath>SAK</SccAuxPath>
    <SccLocalPath>SAK</SccLocalPath>
  </PropertyGroup>

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>

  <PropertyGroup>
    <GenerateDocumentationFile>true</GenerateDocumentationFile>
    <NoWarn>$(NoWarn);1591</NoWarn>
    <UserSecretsId>1d75b031-5ef6-420a-9f88-5b2bb3b78187</UserSecretsId>
    <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
  </PropertyGroup>

  <ItemGroup>
    <Compile Remove="Infrastructure20200116074051_TeamDB.cs" />
    <Compile Remove="Infrastructure20200116074051_TeamDB.Designer.cs" />
    <Compile Remove="InfrastructureMigrations20200116102750_CompanyID.cs" />
    <Compile Remove="InfrastructureMigrations20200116102750_CompanyID.Designer.cs" />
    <Compile Remove="InfrastructureMigrations20200116103510_CompanyIDcccc.cs" />
    <Compile Remove="InfrastructureMigrations20200116103510_CompanyIDcccc.Designer.cs" />
    <Compile Remove="InfrastructureMigrations20200116110757_UserTable.cs" />
    <Compile Remove="InfrastructureMigrations20200116110757_UserTable.Designer.cs" />
    <Compile Remove="InfrastructureMigrations20200116111728_UserTable.cs" />
    <Compile Remove="InfrastructureMigrations20200116111728_UserTable.Designer.cs" />
    <Compile Remove="InfrastructureMigrations20200120064812_new.cs" />
    <Compile Remove="InfrastructureMigrations20200120064812_new.Designer.cs" />
    <Compile Remove="InfrastructureMigrations20200120065302_UpdateUser.cs" />
    <Compile Remove="InfrastructureMigrations20200120065302_UpdateUser.Designer.cs" />
    <Compile Remove="InfrastructureMigrations20200120065757_UpdateUser.cs" />
    <Compile Remove="InfrastructureMigrations20200120065757_UpdateUser.Designer.cs" />
    <Compile Remove="InfrastructureMigrations20200120065948_UpdateUser.cs" />
    <Compile Remove="InfrastructureMigrations20200120065948_UpdateUser.Designer.cs" />
    <Compile Remove="InfrastructureMigrations20200122052759_CompanyUpdate.cs" />
    <Compile Remove="InfrastructureMigrations20200122052759_CompanyUpdate.Designer.cs" />
    <Compile Remove="InfrastructureMigrations20200122063655_UpdateCompanyAndUser.cs" />
    <Compile Remove="InfrastructureMigrations20200122063655_UpdateCompanyAndUser.Designer.cs" />
    <Compile Remove="InfrastructureMigrations20200122064700_UpdateCompany.cs" />
    <Compile Remove="InfrastructureMigrations20200122064700_UpdateCompany.Designer.cs" />
    <Compile Remove="InfrastructureMigrations20200122102506_Updated.cs" />
    <Compile Remove="InfrastructureMigrations20200122102506_Updated.Designer.cs" />
    <Compile Remove="InfrastructureMigrations20200123051214_TeamDB.cs" />
    <Compile Remove="InfrastructureMigrations20200123051214_TeamDB.Designer.cs" />
    <Compile Remove="InfrastructureMigrations20200123133951_CompanyRelation.cs" />
    <Compile Remove="InfrastructureMigrations20200123133951_CompanyRelation.Designer.cs" />
    <Compile Remove="InfrastructureMigrations20200123134744_CompanyRelationUpdate.cs" />
    <Compile Remove="InfrastructureMigrations20200123134744_CompanyRelationUpdate.Designer.cs" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Autofac.Extensions.DependencyInjection" Version="6.0.0" />
    <PackageReference Include="AutoMapper" Version="9.0.0" />
    <PackageReference Include="DocumentFormat.OpenXml" Version="2.10.0" />
    <PackageReference Include="ExceptionHandler" Version="1.0.0-CI-20200424-092531" />
    <PackageReference Include="Hangfire.AspNetCore" Version="1.7.11" />
    <PackageReference Include="HangFire.Core" Version="1.7.11" />
    <PackageReference Include="Hangfire.MemoryStorage" Version="1.7.0" />
    <PackageReference Include="HangFire.SqlServer" Version="1.7.11" />


    <PackageReference Include="MessageBroker" version="1.0.0-CI-20200923-130139"/>
    <PackageReference Include="MessageBrokerRabbitMQ" version="1.0.0-CI-20200923-130139"/>

    <PackageReference Include="linqtotwitter" Version="5.0.0" />

    <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.6" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.RazorPages" Version="2.2.5" />
    <!--<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>-->
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.1" />
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.1" />
    <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.9.10" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.1">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
    <PackageReference Include="EntityFramework" Version="6.4.0" />
    <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="7.0.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.1">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
    <PackageReference Include="RabbitMQ.Client" Version="5.1.2" />
    <PackageReference Include="Serilog" Version="2.9.0" />
    <PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="5.0.0" />
    <PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="5.0.0" />
    <PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="5.0.0" />
    <PackageReference Include="Polly" Version="7.2.0" />
    <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.7.1" />
    <PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="3.0.39" />
  </ItemGroup>


  <!--<ItemGroup>
    <ProjectReference Include="..MessageBrokerRabbitMQMessageBrokerRabbitMQ.csproj" />
    <ProjectReference Include="..MessageBrokerMessageBroker.csproj" />
  </ItemGroup>-->

</Project>

Update2 enter image description here

question from:https://stackoverflow.com/questions/65902619/error-nu1605-docker-restore-nuget-packages-failed

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The RINFeed NuGet Source is missing from your container NuGet config, this source exist in one of your NuGet config hierarchy

You have two choice:

  1. Create a nuget.config (or use the existing with RINFeed) and copy it to the container
    COPY "nuget.config" .

  2. Run a command into the container to add the source
    dotnet nuget add source ....

See this stackoverflow question as a guide.

Warning

The URL in the RINFeed must be resolved by DNS container


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...