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.
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
- Run
dotnet format(without --verify-no-changes) to apply the fixes. - Commit the formatted files.
- Re-run; pin the formatter/SDK version so local and CI agree.
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.