This extension provide a task for checking or fixing code format, style and analyzer configuration using dotnet-format.
Warning
⚠️ The project is still under development.⚠️ Expect breaking changes until v1.
| Requirement | Min. version |
|---|---|
| ADO API | rest-7.1 |
| ADO Agent | 3.227.1 (node v20.x) |
- .NET or .NET Core installed, see Use .NET Core task
- Either:
- .NET 6 / 7 / 8 / 9 / 10 SDK, using
dotnet format - .NET Global tool
dotnet-formatinstalled and accessible from the path
- .NET 6 / 7 / 8 / 9 / 10 SDK, using
Note
dotnet-format is included in the SDK since .NET 6, use this task only if you want to pin a specific version and/or try out dev-build.
Setup pre-release, beta or specific version of
dotnet-formatfrom dnceng feeds.
- task: UseDotNetFormat@1
displayName: 'setup-format feed'
inputs:
publicFeedServiceConnection: PublicDnceng
feed: dotnet9
definition: '54f95428-cc3a-48e0-b6a2-80280b31ba03' # dotnet-format nuget ID
version: 9.0.507701Run
dotnet formatordotnet-formatto validate your code.
Feature:
- check (aka
verify-no-changes) - fix (aka
format) - custom command
Only touched files (onlyChangedFiles: true, Azure DevOps Git only):
- Git (full checkout)
- Azure DevOps (git) (full checkout or API)
- TFVC
- SVN
# Baseline: check all files
- task: DotNetFormatCLI@1
displayName: "dotnet format check"
continueOnError: true # recommended when using ReportReviewer
inputs:
command: 'check'
workspace: 'YourSolution.sln'
verbosity: Normal# PR mode: check only changed files
# Requires Build.Reason = PullRequest; only Azure DevOps Git is supported
- task: DotNetFormatCLI@1
displayName: "dotnet format check (PR)"
continueOnError: true # recommended when using ReportReviewer
inputs:
command: 'check'
workspace: 'YourSolution.sln'
onlyChangedFiles: true
diffProvider: api # `native` requires full (non-shallow) checkout
fileGlobPatterns: |
*.cs
*.vb
excludes: |
/src/Project/FileToExclude.cs
verbosity: Normal
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken) # required for ADO-APIComment an active Azure DevOps PullRequest with previous generated report.
Target:
- Azure DevOps Service
- Azure DevOps Server
- Github
- Github Enterprise Server
- Bitbucket Cloud
- Bitbucket Server
- task: ReportReviewer@1
displayName: "dotnet format reporting"
inputs:
connectedServiceName: 'FormatReviewer' # type: Azure DevOps auth. (report reviewer)
minSeverityLevel: 'warning' # error | warning | info
spamThreshold: 5 # issues per file before grouping into a single thread
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken) # required when auth-scheme-none is usedNote
Only works within a PullRequest build on an Azure DevOps Git repository.
The task reads the report from $(Build.ArtifactStagingDirectory)/CodeAnalysisLogs/format.json produced by DotNetFormatCLI.
If you have feedback or issues, please file an issue on GitHub.





