Recipe for "full" build caching in CI #108847
Replies: 2 comments
-
Perhaps cacheing the https://github.com/actions/cache/blob/main/examples.md#c---nuget |
Beta Was this translation helpful? Give feedback.
-
Yeah, I've tried that both with So I'm looking to cache the result of I've tried caching all But I'm missing something, something is messing up the dotnet internals so that it thinks everything needs to be rebuilt. |
Beta Was this translation helpful? Give feedback.
-
I've tried to find a recipe for a full cache of a dotnet build, but my research hasn't revealed much.
I'm using .NET 8 and Github Actions.
If I run
dotnet build
for my project (ProjectA), it takes me about 2 minutes. If I rerun it, it takes a couple of seconds. So something is obviously being cached.I've tried to solve this in CI using the
actions/cache
GH action, and I do get a cache hit, but the build still takes the full 2 minutes.So obviously I'm missing something and/or doing something wrong.
Here's my latest attempt:
I have more projects in the same repository, some are dependencies to ProjectA.
I've tried using the "built-in" caching that
setup-node
provides, but that seems to only have cached packages.Now, the above CI workflow works, but it doesn't use the cache, as it takes 2 minutes to run
dotnet build
every time.Run actions/cache/restore@v4 Received 192937984 of 230484525 (83.7%), 184.0 MBs/sec Cache Size: ~220 MB (230484525 B) /usr/bin/tar -xf /home/runner/work/_temp/51aa203a-8ad4-4a5f-ad82-33c3559cce54/cache.tzst -P -C /home/runner/work/myproject/myproject --use-compress-program unzstd Received 230484525 of 230484525 (100.0%), 109.7 MBs/sec Cache restored successfully Cache restored from key: Linux-dotnet-build-e207bfd1abb820e61911a2fb949eaf5de507bcaf6fb[40](https://github.com/mycompany/myproject/actions/runs/11329397027/job/31504855445#step:4:41)aaf8ac4947036a8ff6e
Here's an anonymized version of my .csproj file:
Beta Was this translation helpful? Give feedback.
All reactions