我有一个用于dotnet应用程序的docker构建。在较高级别,docker文件具有以下步骤:
这是dockerfile的内容:
FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build
ARG VERSION=0.0.3
ARG RELEASENOTES
ARG PROJECT
ARG ASSEMBLYNAME
WORKDIR /app
COPY . .
RUN dotnet restore $PROJECT
RUN dotnet build -c Release --no-restore $PROJECT
FROM build as test
RUN dotnet restore
RUN dotnet test -c Release --filter FullyQualifiedName!~$PROJECT.IntegrationTests
FROM build as publish
RUN dotnet publish -c Release -o out --no-build $PROJECT
FROM mcr.microsoft.com/dotnet/core/aspnet:3.0 AS runtime
COPY --from=publish /app/out ./
ENTRYPOINT ["dotnet", "$ASSEMBLYNAME.dll"]
一切正常,直到发布步骤出现错误:
/usr/share/dotnet/sdk/3.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error NETSDK1004: Assets file '/app/Service.UnitTests/obj/project.assets.json' not found. Run a NuGet package restore to generate this file. [/app/Service.UnitTests/Service.UnitTests.csproj]
PayPalClient -> /app/out/
/usr/share/dotnet/sdk/3.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error NETSDK1004: Assets file '/app/PayPalClient.IntegrationTests/obj/project.assets.json' not found. Run a NuGet package restore to generate this file. [/app/PayPalClient.IntegrationTests/PayPalClient.IntegrationTests.csproj]
/usr/share/dotnet/sdk/3.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error NETSDK1004: Assets file '/app/PayPalClient.UnitTests/obj/project.assets.json' not found. Run a NuGet package restore to generate this file. [/app/PayPalClient.UnitTests/PayPalClient.UnitTests.csproj]
我知道这是说我尚未还原这些项目,但我不想还原它们。它们是测试项目,不应成为最终输出的一部分。
对于它的价值,我可以在命令行中运行这些命令,就像在此dockerfile中一样,并且一切正常。我看到此错误只是docker build
的一部分。
我在做什么错了?