Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Repo Assist] [Eng] Add NuGet and npm package caching to CI workflow#4525

Draft
dbrattli wants to merge 2 commits into
main from
repo-assist/eng-ci-nuget-npm-caching-2026-04-de479ba7cc732133
Draft

[Repo Assist] [Eng] Add NuGet and npm package caching to CI workflow #4525
dbrattli wants to merge 2 commits into
main from
repo-assist/eng-ci-nuget-npm-caching-2026-04-de479ba7cc732133

Conversation

@dbrattli

@dbrattli dbrattli commented Apr 11, 2026

Copy link
Copy Markdown
Collaborator

Add cache: true + cache-dependency-path to all setup-dotnet steps to
cache ~/.nuget/packages across job runs. Add cache: npm to all
setup-node steps to cache the npm download cache.

This eliminates redundant package downloads on every CI run. The NuGet
cache key is keyed on the hash of all .fsproj files, so it invalidates
automatically when dependencies change.

Closes #4486

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

github-actions Bot and others added 2 commits April 11, 2026 09:12
Add cache: true + cache-dependency-path to all setup-dotnet steps to
cache ~/.nuget/packages across job runs. Add cache: npm to all
setup-node steps to cache the npm download cache.
This eliminates redundant package downloads on every CI run. The NuGet
cache key is keyed on the hash of all .fsproj files, so it invalidates
automatically when dependencies change.
Closes #4486
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copy link
Copy Markdown
Collaborator Author

Note on NuGet caching correctness

The setup-dotnet cache: true feature is designed to work with NuGet lock files (packages.lock.json), not .fsproj files. Using **/*.fsproj as the cache-dependency-path means the cache key won't capture transitive dependency version changes — if a transitive package gets a new version but no .fsproj changes, CI will restore stale cached packages.

For correct caching, the intended setup is:

  1. Add <RestorePackagesWithLockFile>true</RestorePackagesWithLockFile> to project files (or Directory.Build.props)
  2. Commit the generated packages.lock.json files
  3. Use cache-dependency-path: "**/packages.lock.json"
  4. Use dotnet restore --locked-mode so restore fails if the lock file is out of date

Reference: https://www.damirscorner.com/blog/posts/20240726-CachingNuGetPackagesInGitHubActions.html

This also has the benefit of reproducible builds beyond just caching. Worth considering whether we want to adopt lock files across the repo before merging this.

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[Repo Assist] [Eng] Add NuGet and npm caching to CI workflow

1 participant

AltStyle によって変換されたページ (->オリジナル) /