Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error NETSDK1064: Package DnsClient, 1.2.0 was not found

I have an Asp.Net core docker image. The last time I tried building it was 2 months ago. Now, I'm getting an error while trying to build it.

Any ideas? Did something break the Microsoft docker image? This is also breaking when trying to publish and run on an Elasticbeanstalk instance.

Complete Error Log:

/usr/share/dotnet/sdk/3.1.201/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error NETSDK1064: Package DnsClient, version 1.2.0 was not found. It might have been deleted since NuGet restore. Otherwise, NuGet restore might have only partially completed, which might have been due to maximum path length restrictions. [/app/BacktraderDataApi.csproj]
The command '/bin/sh -c dotnet publish -c Release -o out' returned a non-zero code: 1

Dockerfile:

FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
WORKDIR /app

COPY *.csproj ./
RUN dotnet restore

COPY . ./
RUN dotnet publish -c Release -o out

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
WORKDIR /app
COPY --from=build-env /app/out .
EXPOSE 5000
ENTRYPOINT ["dotnet", "myApp.dll"]
like image 726
user714157 Avatar asked Apr 12 '20 04:04

user714157


3 Answers

Based on the information posted at https://github.com/microsoft/containerregistry/issues/20 for this same issue as well as the information here I tried the following:

  1. dotnet new web
  2. Edit the csproj and added the following:
  <ItemGroup>
    <PackageReference Include="MongoDB.Driver" Version="2.10.1" />
    <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
  </ItemGroup>
  1. Created the following Dockerfile
# https://hub.docker.com/_/microsoft-dotnet-core
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /source

# copy csproj and restore as distinct layers
COPY *.csproj .
RUN dotnet restore

# copy and publish app and libraries
COPY . .
RUN dotnet publish -c release -o /app --no-restore


# final stage/image
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
WORKDIR /app
COPY --from=build /app ./
ENTRYPOINT ["dotnet", "aspnetapp.dll"]
  1. Created the following .dockerignore
# directories
**/bin/
**/obj/
**/out/

# files
Dockerfile*
**/*.trx
**/*.md
**/*.ps1
**/*.cmd
**/*.sh
  1. docker build --pull -t test .

The Dockerfile built without issue. Can you try these steps and report back the results?

like image 85
msimons Avatar answered Oct 12 '22 11:10

msimons


For me it helped adding a --no-cache flag

RUN dotnet publish -c Release -o out --no-cache
like image 43
ekimpl Avatar answered Oct 12 '22 11:10

ekimpl


I had a very similar problem

error MSB4018: NuGet.Packaging.Core.PackagingException: Unable to find fallback package folder '/usr/local/share/dotnet/sdk/NuGetFallbackFolder'.

I added RUN mkdir -p /usr/local/share/dotnet/sdk/NuGetFallbackFolder.

Then it got a lot farther but failed with a library resolution for something that I believe is just distributed with the SDK.

/usr/share/dotnet/sdk/3.1.201/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error NETSDK1064: Package Microsoft.EntityFrameworkCore.Analyzers, version 3.1.1 was not found. It might have been deleted since NuGet restore. Otherwise, NuGet restore might have only partially completed, which might have been due to maximum path length restrictions. 

I think the mcr.microsoft.com/dotnet/core/sdk:3.1 4/09/2010 Docker image with tags 3.1.201-buster, 3.1-buster, 3.1.201, 3.1, latest is broken.

I changed to the image based on Ubuntu bionic and it just worked again.

USE mcr.microsoft.com/dotnet/core/sdk:3.1-bionic
like image 25
Brian Reiter Avatar answered Oct 12 '22 10:10

Brian Reiter