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"]
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:
dotnet new web
<ItemGroup>
<PackageReference Include="MongoDB.Driver" Version="2.10.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>
# 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"]
# directories
**/bin/
**/obj/
**/out/
# files
Dockerfile*
**/*.trx
**/*.md
**/*.ps1
**/*.cmd
**/*.sh
docker build --pull -t test .
The Dockerfile built without issue. Can you try these steps and report back the results?
For me it helped adding a --no-cache flag
RUN dotnet publish -c Release -o out --no-cache
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With