Skip to content
Latchkey

dotnet format --verify-no-changes failed in CI

A dotnet format --verify-no-changes step is a read-only gate: it exits non-zero if running the formatter would change any file. The failure is not a bug - it means code in the PR does not match the formatting, whitespace, or analyzer style rules the repo enforces.

What this error means

The format step exits non-zero and lists files that would be changed, with the diagnostics that triggered it. It is deterministic for the committed code.

dotnet
Formatted code file 'src/Api/Service.cs'.
  Unable to verify: the file requires formatting changes.
dotnet format exited with non-zero exit code.

Common causes

Code was committed unformatted

Whitespace, ordering, or style rules in .editorconfig were not applied before committing, so the verify gate fails.

A version skew between local and CI formatter

A different dotnet format / SDK version applies slightly different rules than the developer ran locally.

How to fix it

Format locally and commit

  1. Run dotnet format (without --verify-no-changes) to apply the fixes.
  2. Commit the formatted files.
  3. Re-run; pin the formatter/SDK version so local and CI agree.
shell
dotnet format
git add -A && git commit -m "Apply dotnet format"

How to prevent it

  • Add a pre-commit hook or local task that runs dotnet format.
  • Pin the SDK version so the formatter behaves identically in CI and locally.

Frequently asked questions

What causes ""dotnet format ... would have changed files""?
Whitespace, ordering, or style rules in .editorconfig were not applied before committing, so the verify gate fails.
How do I fix "dotnet format ... would have changed files"?
Format locally and commit

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card