Skip to content

ci: add NuGet package cache to speed up CI#28

Merged
NichUK merged 3 commits into
mainfrom
copilot/add-nuget-package-cache-again
Jun 17, 2026
Merged

ci: add NuGet package cache to speed up CI#28
NichUK merged 3 commits into
mainfrom
copilot/add-nuget-package-cache-again

Conversation

Copilot AI commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Each matrix leg (net8.0, net9.0, net10.0) downloads all NuGet packages from scratch on every run. This adds actions/cache@v4 to cache ~/.nuget/packages, reducing dotnet restore time from ~30–60s to ~1–2s on cache hits.

Changes

  • .github/workflows/dotnet.yml — inserts a Cache NuGet packages step between Setup .NET and Restore:
- name: Cache NuGet packages
  uses: actions/cache@v4
  with:
    path: ~/.nuget/packages
    key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
    restore-keys: |
      ${{ runner.os }}-nuget-

Cache key is invalidated on any .csproj change; restore key falls back to the latest same-OS cache for a partial hit. Cache is OS-scoped (not per-framework) since ~/.nuget/packages is framework-agnostic.

@NichUK NichUK marked this pull request as ready for review June 17, 2026 14:39
Copilot AI review requested due to automatic review settings June 17, 2026 14:39
@NichUK

NichUK commented Jun 17, 2026

Copy link
Copy Markdown
Owner

@copilot resolve the merge conflicts in this pull request

Copilot AI changed the title [WIP] Add NuGet package cache to speed up CI ci: add NuGet package cache to speed up CI Jun 17, 2026
Copilot AI requested a review from NichUK June 17, 2026 14:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR speeds up the repository’s GitHub Actions CI by caching the NuGet global packages folder so repeated runs don’t re-download dependencies for each matrix leg.

Changes:

  • Added an actions/cache@v4 step to cache ~/.nuget/packages between actions/setup-dotnet@v4 and dotnet restore.
  • Cache key is scoped by OS and invalidated when any *.csproj changes, with an OS-scoped restore key fallback.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

Merged main into this branch and resolved the conflict in .github/workflows/dotnet.yml. The only clash was the cache-key prefix (nuget-${{ runner.os }}- vs ${{ runner.os }}-nuget-); I adopted the format that's already live on main (${{ runner.os }}-nuget-). Merge commit: 76ef3e8.

@NichUK NichUK merged commit 4f52943 into main Jun 17, 2026
3 checks passed
@NichUK NichUK deleted the copilot/add-nuget-package-cache-again branch June 17, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants