Replies: 2 comments 3 replies
-
It’s a best practice because each |
Beta Was this translation helpful? Give feedback.
-
Yes, using cache mounts for NuGet packages is a good solution and it can offer similar or better performance to using Docker's layer caching for local dev workflows. The benefit is amplified when you are building multiple projects that share dependencies. You can even cache .NET's build outputs like so:
As for why it's not the default in the samples, I think it's a combination of:
We would happily take community contributions in this area (Issues or Pull Requests)! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've reviewed the different samples and most samples with Docker suggest putting the nuget restore into a separate build stage, copying only the *.csproj files to perform the restore.
However, I'm curious why it's done this way. I've found that simply declaring the global nuget caching folder as an explicit cache mount results in extremely similar build performance while simplifying the setup for multi-folder/multi-project solutions.
Is there a particular reason all the samples do that or is this perhaps another example to share with the community? We found this particular setup worked well for our fairly large project (20ish project references with a custom secured nuget repository). I did see this question was similar, but didn't offer the solution we ultimately landed on as an alternative approach: Previously posted question
Dockerfile example caching nuget without separating from publish:
Beta Was this translation helpful? Give feedback.
All reactions