❔ Can't restore public nuget packages while building docker image
[build 10/10] RUN dotnet publish -c release -o /app --no-restore:
#0 0.362 MSBuild version 17.5.0+6f08c67f3 for .NET
#0 0.796 /usr/share/dotnet/sdk/7.0.202/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(266,5): error NETSDK1064: Package Microsoft.Extensions.Logging.Abstractions, version 7.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.
7 Replies
I'm learning now that net 7 introduced a microsoft container builder...
https://github.com/dotnet/sdk-container-builds
GitHub
GitHub - dotnet/sdk-container-builds: Experimental OCI containers l...
Experimental OCI containers libraries and tasks. Contribute to dotnet/sdk-container-builds development by creating an account on GitHub.
going to mess with that
That's pretty cool.
But I'd still like to know what went wrong.
Some project file might conditionally reference that package based on configuration or some other property, which make dotnet restore not download all packages that are needed for build. After that you're doing a build without restore, but a release build has other constants defined than debug.
that's my guess
try passing the configuration flag to restore (it supports that, right?)
or just remove --no-restorw
and the restore before
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.