The projects that are not loading are on the same level as the Auth.Api
project. Debug build is okay, but release build is not.
Docker file:
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["Auth.Api/Auth.Api.csproj", "Auth.Api/"]
RUN dotnet restore "./Auth.Api/Auth.Api.csproj"
COPY . .
WORKDIR "/src/Auth.Api"
RUN dotnet build "./Auth.Api.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./Auth.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Auth.Api.dll"]
I try build with release configuration.
Build Output:
1 docker-compose -f "C:UsersMátéDesktopAuthSolutionAuthSolutionAuthdocker-compose.yml" -f "C:UsersMátéDesktopAuthSolutionAuthSolutionAuthdocker-compose.override.yml" -p dockercompose16918967173923667077 --ansi never build --build-arg BUILD_CONFIGURATION=Release
1 #1 [auth.api internal] load .dockerignore
1 #1 transferring context: 464B done
1 #1 DONE 0.0s
1 #2 [auth.api internal] load build definition from Dockerfile
1 #2 transferring dockerfile: 886B done
1 #2 DONE 0.0s
1 #3 [auth.api internal] load metadata for mcr.microsoft.com/dotnet/aspnet:8.0
1 #3 DONE 0.0s
1 #4 [auth.api internal] load metadata for mcr.microsoft.com/dotnet/sdk:8.0
1 #4 DONE 0.1s
1 #5 [auth.api build 1/7] FROM mcr.microsoft.com/dotnet/sdk:8.0@sha256:a364676fedc145cf88caad4bfb3cc372aae41e596c54e8a63900a2a1c8e364c6
1 #5 DONE 0.0s
1 #6 [auth.api base 1/2] FROM mcr.microsoft.com/dotnet/aspnet:8.0
1 #6 DONE 0.0s
1 #7 [auth.api base 2/2] WORKDIR /app
1 #7 CACHED
1 #8 [auth.api final 1/2] WORKDIR /app
1 #8 CACHED
1 #9 [auth.api internal] load build context
1 #9 transferring context: 10.00kB 0.1s done
1 #9 DONE 0.1s
1 #10 [auth.api build 2/7] WORKDIR /src
1 #10 CACHED
1 #11 [auth.api build 3/7] COPY [Auth.Api/Auth.Api.csproj, Auth.Api/]
1 #11 CACHED
1 #12 [auth.api build 4/7] RUN dotnet restore "./Auth.Api/Auth.Api.csproj"
1 #12 1.229 Determining projects to restore...
1 #12 1.234 Skipping project "/Auth.Shared/Auth.Shared.csproj" because it was not found.
1 #12 1.234 Skipping project "/src/Auth.Application/Auth.Application.csproj" because it was not found.
1 #12 1.234 Skipping project "/src/Auth.Domain/Auth.Domain.csproj" because it was not found.
1 #12 1.234 Skipping project "/src/Auth.Infra/Auth.Infra.csproj" because it was not found.
1 #12 1.236 Skipping project "/Auth.Shared/Auth.Shared.csproj" because it was not found.
1 #12 1.236 Skipping project "/src/Auth.Application/Auth.Application.csproj" because it was not found.
1 #12 1.236 Skipping project "/src/Auth.Domain/Auth.Domain.csproj" because it was not found.
1 #12 1.236 Skipping project "/src/Auth.Infra/Auth.Infra.csproj" because it was not found.
1 #12 17.95 /src/Auth.Api/Auth.Api.csproj : warning NU1604: Project dependency Base.Api does not contain an inclusive lower bound. Include a lower bound in the dependency version to ensure consistent restore results.
1 #12 17.95 /src/Auth.Api/Auth.Api.csproj : warning NU1604: Project dependency Base.Application does not contain an inclusive lower bound. Include a lower bound in the dependency version to ensure consistent restore results.
1 #12 17.95 /src/Auth.Api/Auth.Api.csproj : warning NU1604: Project dependency Base.Domain does not contain an inclusive lower bound. Include a lower bound in the dependency version to ensure consistent restore results.
1 #12 17.95 /src/Auth.Api/Auth.Api.csproj : warning NU1604: Project dependency MediatR does not contain an inclusive lower bound. Include a lower bound in the dependency version to ensure consistent restore results.
1 #12 17.95 /src/Auth.Api/Auth.Api.csproj : warning NU1604: Project dependency Serilog does not contain an inclusive lower bound. Include a lower bound in the dependency version to ensure consistent restore results.
1 #12 17.95 /src/Auth.Api/Auth.Api.csproj : warning NU1604: Project dependency Serilog.Sinks.File does not contain an inclusive lower bound. Include a lower bound in the dependency version to ensure consistent restore results.
1 #12 17.95 /src/Auth.Api/Auth.Api.csproj : warning NU1604: Project dependency Serilog.Sinks.Seq does not contain an inclusive lower bound. Include a lower bound in the dependency version to ensure consistent restore results.
1 #12 17.96 /src/Auth.Api/Auth.Api.csproj : error NU1101: Unable to find package Base.Application. No packages exist with this id in source(s): nuget.org
1 #12 18.16 /src/Auth.Api/Auth.Api.csproj : warning NU1701: Package 'MediatR 0.1.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework 'net8.0'. This package may not be fully compatible with your project.
1 #12 18.18 /src/Auth.Api/Auth.Api.csproj : warning NU1701: Package 'Portable.CommonServiceLocator 1.2.2' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework 'net8.0'. This package may not be fully compatible with your project.
1 #12 18.18 /src/Auth.Api/Auth.Api.csproj : warning NU1701: Package 'Serilog 0.1.6' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework 'net8.0'. This package may not be fully compatible with your project.
1 #12 18.19 /src/Auth.Api/Auth.Api.csproj : warning NU1701: Package 'Serilog.Sinks.Seq 1.4.4' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework 'net8.0'. This package may not be fully compatible with your project.
1 #12 18.27 Failed to restore /src/Auth.Api/Auth.Api.csproj (in 16.65 sec).
1 #12 ERROR: process "/bin/sh -c dotnet restore "./Auth.Api/Auth.Api.csproj"" did not complete successfully: exit code: 1
1 failed to solve: process "/bin/sh -c dotnet restore "./Auth.Api/Auth.Api.csproj"" did not complete successfully: exit code: 1
1 ------
1 [auth.api build 4/7] RUN dotnet restore "./Auth.Api/Auth.Api.csproj":
1 17.95 /src/Auth.Api/Auth.Api.csproj : warning NU1604: Project dependency MediatR does not contain an inclusive lower bound. Include a lower bound in the dependency version to ensure consistent restore results.
1 17.95 /src/Auth.Api/Auth.Api.csproj : warning NU1604: Project dependency Serilog does not contain an inclusive lower bound. Include a lower bound in the dependency version to ensure consistent restore results.
1 17.95 /src/Auth.Api/Auth.Api.csproj : warning NU1604: Project dependency Serilog.Sinks.File does not contain an inclusive lower bound. Include a lower bound in the dependency version to ensure consistent restore results.
1 17.95 /src/Auth.Api/Auth.Api.csproj : warning NU1604: Project dependency Serilog.Sinks.Seq does not contain an inclusive lower bound. Include a lower bound in the dependency version to ensure consistent restore results.
1 17.96 /src/Auth.Api/Auth.Api.csproj : error NU1101: Unable to find package Base.Application. No packages exist with this id in source(s): nuget.org
1 18.16 /src/Auth.Api/Auth.Api.csproj : warning NU1701: Package 'MediatR 0.1.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework 'net8.0'. This package may not be fully compatible with your project.
1 18.18 /src/Auth.Api/Auth.Api.csproj : warning NU1701: Package 'Portable.CommonServiceLocator 1.2.2' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework 'net8.0'. This package may not be fully compatible with your project.
1 18.18 /src/Auth.Api/Auth.Api.csproj : warning NU1701: Package 'Serilog 0.1.6' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework 'net8.0'. This package may not be fully compatible with your project.
1 18.19 /src/Auth.Api/Auth.Api.csproj : warning NU1701: Package 'Serilog.Sinks.Seq 1.4.4' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework 'net8.0'. This package may not be fully compatible with your project.
1 18.27 Failed to restore /src/Auth.Api/Auth.Api.csproj (in 16.65 sec).
I suspect that you’ve made changes to your project since scaffolding the Dockerfile that aren’t reflected in the Dockerfile (for instance project references). Try regenerating the file in VS by right clicking on the project and selecting Add->Docker Support.
Specific errors of note:
error NU1101 : You probably have package sources configured locally that need to be configured inside the container. Assuming your repo has a NuGet.config you need to copy that in before the restore. If you’ve configured the package source in VS, you’ll need to make a Nuget.config to copy into the container or use the dotnet commands in the Dockerfile to add those package sources to your build stage.
warning NU1604 : Are you using a Directory.Packages.props
andor a Directory.Build.props
to set your pacakge reference versions? If so you need to copy those files before doing the restore.
Skipping project _ because it was not found : Your Dockerfile is not copying all of the referenced projects before calling restore which may cause build issues once you resolve the restore issues for this project.
For the missing files: For fastest incremental image build I recommend editing the Dockerfile to add the specific files before doing the restore (If you regenerate in the latest VS it should do this for you). If you’re not worried about incremental image build performance, you can instead move the restore to after the COPY . .
to ensure that everything is copied first.