Skip to content

Give the lock-file chore a button, and a failure that names it - #72

Merged
ivanvyd merged 1 commit into
mainfrom
chore/lockfile-refresh-workflow
Aug 14, 2026
Merged

Give the lock-file chore a button, and a failure that names it#72
ivanvyd merged 1 commit into
mainfrom
chore/lockfile-refresh-workflow

Conversation

@ivanvyd

@ivanvyd ivanvyd commented Aug 14, 2026

Copy link
Copy Markdown
Owner

Four Dependabot PRs failed this week for the same reason, and each was fixed by hand.

The constraint

Dependabot edits Directory.Packages.props but cannot rewrite packages.lock.json — the CentralTransitive entries have to be resolved by NuGet, not pattern-matched. So every NuGet bump arrives with lock files naming the old versions and dies at dotnet restore --locked-mode before anything builds:

error NU1004: Mistmatch between the requestedVersion of a lock file dependency marked as
CentralTransitive and the version specified in the central package management file.

What this adds

  • Refresh lock files — a workflow_dispatch job. Give it a branch; it runs --force-evaluate, proves the result with --locked-mode and a Release build before committing, and commits only **/packages.lock.json by name. contents: write is scoped to that single job, not the workflow.
  • A restore failure that names its own fix. NU1004's text does not mention lock files needing regeneration, let alone how. CI now says which workflow to run and on which branch.
  • The constraint documented beside the nuget ecosystem in dependabot.yml.

Why a button and not an automatic push

This was my first instinct and it does not work. A push made with GITHUB_TOKEN does not re-trigger workflows — by design, to prevent loops. An auto-commit bot would push the fix and leave the required checks pinned to the superseded commit: one stall traded for another.

Making it automatic requires a PAT or a GitHub App private key. This repository stores no such credential deliberately — SECURITY.md states publishing uses OIDC and "No publishing key is stored". Adding a long-lived write credential to automate a dependency chore is the wrong trade, so the human keeps the write and gets a button.

Dependabot edits Directory.Packages.props but cannot rewrite packages.lock.json:
the CentralTransitive entries have to be resolved by NuGet rather than
pattern-matched. So every NuGet bump lands with stale lock files and dies at
`dotnet restore --locked-mode` with NU1004, before anything is built. That
happened to four PRs this week and each one was fixed by hand.

Three changes, none of which give a bot write access:

- `Refresh lock files`, a workflow_dispatch job that regenerates the lock files
  on a named branch, proves the result with `--locked-mode` and a Release build,
  and commits only `**/packages.lock.json`. `contents: write` is scoped to that
  one job.
- CI's restore step is named and, on failure, says which workflow to run and on
  which branch. NU1004's own text does not mention the fix.
- The constraint is written down beside the nuget ecosystem in dependabot.yml,
  where the next person meets it.

Deliberately a button rather than an automatic push on every Dependabot PR: a
push made with GITHUB_TOKEN does not re-trigger workflows, so an automatic
version would commit the fix and leave the required checks pinned to the
superseded commit -- one stall traded for another. Making it automatic needs a
PAT or a GitHub App key, and this repository stores no such credential on
purpose.
@ivanvyd
ivanvyd merged commit 0ec7da5 into main Aug 14, 2026
10 checks passed
@ivanvyd
ivanvyd deleted the chore/lockfile-refresh-workflow branch August 14, 2026 04:16
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.

1 participant