Skip to content

[Repo Assist] ci: cache NuGet packages to speed up builds #234

Description

@github-actions

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

Adds actions/cache@v4 to cache the ~/.nuget/packages directory in the CI workflow, keyed on the paket.lock hash.

Motivation

Each CI run currently downloads all NuGet packages from scratch during dotnet paket restore. The full build takes ~4 minutes, with a noticeable portion spent on package downloads. Caching packages by paket.lock hash means:

  • Cache hit (no lockfile change): packages are restored from cache, saving download time
  • Cache miss (lockfile changed): packages are downloaded and the new cache is saved for subsequent runs

The cache key falls back to ${{ runner.os }}-nuget- so partial cache hits still benefit from previously downloaded packages.

Changes

  • .github/workflows/dotnet.yml: add Cache NuGet packages step using actions/cache@v4 between Setup .NET Core and Install local tools

Test Status

This is a CI-only change with no impact on the build output or test results. The workflow syntax is valid YAML and follows the actions/cache documentation. No local build run required.

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@30f2254f2a7a944da1224df45d181a3f8faefd0d

Note

This was originally intended as a pull request, but the git push operation failed.

Workflow Run: View run details and download patch artifact

The patch file is available in the agent-artifacts artifact in the workflow run linked above.

To create a pull request with the changes:

# Download the artifact from the workflow run
gh run download 22826651287 -n agent-artifacts -D /tmp/agent-artifacts-22826651287

# Create a new branch
git checkout -b repo-assist/eng-ci-cache-2026-03-08-3f86249ea8ef643c

# Apply the patch (--3way handles cross-repo patches where files may already exist)
git am --3way /tmp/agent-artifacts-22826651287/aw-repo-assist-eng-ci-cache-2026-03-08.patch

# Push the branch to origin
git push origin repo-assist/eng-ci-cache-2026-03-08-3f86249ea8ef643c

# Create the pull request
gh pr create --title '[Repo Assist] ci: cache NuGet packages to speed up builds' --base master --head repo-assist/eng-ci-cache-2026-03-08-3f86249ea8ef643c --repo fsprojects/FSharpx.Collections
Show patch (37 lines)
From 4bfe3b7aadebc970aa577fd65150bcc5475f15c9 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Sun, 8 Mar 2026 18:10:26 +0000
Subject: [PATCH] ci: cache NuGet packages to speed up builds

Add actions/cache@v4 to cache the ~/.nuget/packages directory,
keyed on paket.lock hash. This avoids re-downloading packages on
every CI run, which should significantly reduce build times on
cache hits.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
 .github/workflows/dotnet.yml | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml
index aea2abe..fae97c1 100644
--- a/.github/workflows/dotnet.yml
+++ b/.github/workflows/dotnet.yml
@@ -36,6 +36,13 @@ jobs:
       uses: actions/setup-dotnet@v5
       with:
         dotnet-version: ${{ matrix.dotnet }}
+    - name: Cache NuGet packages
+      uses: actions/cache@v4
+      with:
+        path: ~/.nuget/packages
+        key: ${{ runner.os }}-nuget-${{ hashFiles('**/paket.lock') }}
+        restore-keys: |
+          ${{ runner.os }}-nuget-
     - name: Install local tools
       run: dotnet tool restore
     - name: Paket Restore
-- 
2.53.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions