This extension provide a task for checking or fixing code format, style and analyzer configuration using dotnet-format.
Disclaimer
[!WARNING]
- ⚠️ The project is still under development.
- ⚠️ Expect breaking changes until v1.
How to use
Compatibility matrix
Requirement |
Min. version |
ADO API |
rest-7.1 0 |
ADO Agent |
2.206.1 (node v16.x) |
Pre-requisites
- .NET or .NET Core installed, see Use .NET Core task
- Either:
- .NET 6 / 7 / 8 SDK, using
dotnet format
- .NET Global tool
dotnet-format installed and accessible from the path
Tasks
Setup pre-release, beta or specific version of dotnet-format from dnceng feeds.
- task: UseDotNetFormat@0
displayName: 'setup-format feed'
inputs:
publicFeedServiceConnection: PublicDnceng
feed: dotnet9
definition: '54f95428-cc3a-48e0-b6a2-80280b31ba03'
version: 9.0.507701
Run dotnet format or dotnet-format to validate your code.
Feature:
- [X] check (aka
verify-no-changes )
- [ ] fix (aka
format )
- [ ] custom command
Only touched files:
- [X] Git (full checkout or ADO-API)
- [ ] TFVC
- [ ] SVN
- task: DotNetFormatCLI@0
displayName: "dotnet format"
continueOnError: true # recommended if using ReportReviewer
inputs:
useGlobalTool: false
command: 'check'
workspace: 'YourSolution.sln'
onlyChangedFiles: true #PR mode
verbosity: Normal
diffProvider: api # `native` using full checkout or `api` using ADO-API
fileGlobPatterns: |
*.cs
*.vb
excludes: |
/src/Project/FileToExclude.cs
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken) # required for ADO-API
ReportReviewer
Comment an active Azure DevOps PullRequest with previous generated report.
Target:
- [X] Azure DevOps Service
- [X] Azure DevOps Server
- [ ] Github
- [ ] Github Enterprise Server
- [ ] Bitbucket Cloud
- [ ] Bitbucket Server
- task: ReportReviewer@0
displayName: "dotnet format reporting"
inputs:
connectedServiceName: 'FormatReviewer'
spamThreshold: 5
Feedback and issues
If you have feedback or issues, please file an issue on GitHub.
| |