内容来源于 Stack Overflow,遵循 CC BY-SA 4.0 许可协议进行翻译与使用。IT领域专用引擎提供翻译支持
腾讯云小微IT领域专用引擎提供翻译支持
我正在尝试用.net核心6构建一个映像,但是当命令运行到这一行时:
RUN dotnet publish -c release -o /app --no-restore
我有个错误:
/usr/share/dotnet/sdk/6.0.101/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(267,5):#14 0.629
错误NETSDK1064:没有找到软件包Microsoft.EntityFrameworkCore.Analyzers,版本6.0.1。它可能在NuGet恢复后被删除了。否则,NuGet还原可能只有部分完成,这可能是由于最大路径长度限制所致。/出处/测年_WebAPI.csproj
所以我检查了我的nuget经理,我以前没有下载这个软件包。但是即使我下载了它,这个错误仍然会发生。
我错过了什么吗?
以下Dockerfile:
# https://hub.docker.com/_/microsoft-dotnet FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /source # copy csproj and restore as distinct layers COPY *.csproj . RUN dotnet restore # copy everything else and build app COPY . . RUN dotnet publish -c release -o /app --no-restore # final stage/image FROM mcr.microsoft.com/dotnet/aspnet:6.0 WORKDIR /app COPY --from=build /app . ENTRYPOINT ["dotnet", "aspnetapp.dll"]
码头文件的步骤:
[+] 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