I'm tring to build a image with .net core 6, but when command ran to this line :
RUN dotnet publish -c release -o /app --no-restore
I got a error:
#14 0.629 /usr/share/dotnet/sdk/6.0.101/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(267,5):
error NETSDK1064: Package Microsoft.EntityFrameworkCore.Analyzers,version 6.0.1 was not found. It might have been deleted since NuGetrestore. Otherwise, NuGet restore might have only partially completed,which might have been due to maximum path length restrictions.[/source/Dating_WebAPI.csproj]
so I checked my nuget manager, I dont download this package before.but even I download it, the error still occur.
Did I miss something?
following Dockerfile:
# https://hub.docker.com/_/microsoft-dotnetFROM mcr.microsoft.com/dotnet/sdk:6.0 AS buildWORKDIR /source# copy csproj and restore as distinct layersCOPY *.csproj .RUN dotnet restore# copy everything else and build appCOPY . .RUN dotnet publish -c release -o /app --no-restore# final stage/imageFROM mcr.microsoft.com/dotnet/aspnet:6.0WORKDIR /appCOPY --from=build /app .ENTRYPOINT ["dotnet", "aspnetapp.dll"]
step of dockerfile:
[+] Building 12.2s (14/15) => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 768B 0.0s => [internal] load .dockerignore 0.0s => => transferring context: 2B 0.0s => [internal] load metadata for mcr.microsoft.com/dotnet/aspnet:latest 0.3s => [internal] load metadata for mcr.microsoft.com/dotnet/sdk:latest 0.2s => [internal] load build context 0.5s => => transferring context: 17.79MB 0.5s => [build 1/7] FROM mcr.microsoft.com/dotnet/sdk@sha256:a7af03bdead8976d4e3715452fc985164db56840691941996202cea411953452 0.0s => [stage-1 1/3] FROM mcr.microsoft.com/dotnet/aspnet@sha256:7696d5b456eede87434c232b9070f40659ff0c4b71ca622cf197815ccaee661d 0.0s => CACHED [stage-1 2/3] WORKDIR /app 0.0s => CACHED [build 2/7] WORKDIR /source 0.0s => [build 3/7] COPY *.csproj . 0.0s => [build 4/7] RUN dotnet clean 0.5s => [build 5/7] RUN dotnet restore 10.1s => [build 6/7] COPY . . 0.1s => ERROR [build 7/7] RUN dotnet publish -c release -o /app --no-restore