-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
Description
Describe the bug
dotnet publish --no-restore
fails during docker build
even if the packages are already restored. The app is a .NET 8 web api with a dependent class library.
To Reproduce
All the steps in reproducing this issue are documented in this minimalistic repro project:
https://github.com/akhanalcs/docker-with-classlib
In nutshell, the issue is that it's not possible to create a docker image without restoring the packages twice, once during dotnet restore
and other during dotnet publish
. If you use --no-restore
flag in dotnet publish
even AFTER doing dotnet restore
, the image build fails with this error:
> [build 9/9] RUN dotnet publish --no-restore -o /app:
2.203 MSBuild version 17.8.3+195e7f5a3 for .NET
3.378 /usr/share/dotnet/sdk/8.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(266,5): error NETSDK1064: Package Microsoft.AspNetCore.OpenApi, version 8.0.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. [/source/MyCoolTestApp.API/MyCoolTestApp.API.csproj]
ERROR: failed to solve: process "/bin/sh -c dotnet publish --no-restore -o /app" did not complete successfully: exit code: 1
Exceptions (if any)
Further technical details
- Include the output of
dotnet --info
.NET SDK: Version: 8.0.100 Commit: 57efcf1350 Workload version: 8.0.100-manifests.d43d43dc Runtime Environment: OS Name: Mac OS X OS Version: 14.1 OS Platform: Darwin RID: osx-x64 Base Path: /usr/local/share/dotnet/sdk/8.0.100/ .NET workloads installed: Workload version: 8.0.100-manifests.d43d43dc There are no installed workloads to display. Host: Version: 8.0.0 Architecture: x64 Commit: 5535e31a71 .NET SDKs installed: 7.0.308 [/usr/local/share/dotnet/sdk] 8.0.100 [/usr/local/share/dotnet/sdk] .NET runtimes installed: Microsoft.AspNetCore.App 7.0.11 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 8.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 7.0.11 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 8.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Other architectures found: None Environment variables: Not set global.json file: Not found Learn more: https://aka.ms/dotnet/info Download .NET: https://aka.ms/dotnet/download
- The IDE (VS / VS Code/ VS4Mac) you're running on, and its version
JetBrains Rider 2023.2.3
bencoveney, akhanalcs, felipetofoli, JRWinter1, maxsargentdev and 6 moreSeabizkit