🎉🥳 dotnet-format is now part of the .NET 6 SDK
See original GitHub issueStarting with the .NET 6 Preview 7, which is available now, dotnet format
is a built-in SDK command. As part of this move the options have changed a bit.
Invoking the SDKs dotnet format
command will fix whitespace, code style, and analyzer issues by default.
There are also 3 subcommands to target specific scenarios:
dotnet format whitespace
: fixes whitespacedotnet format style
: runs code style analyzersdotnet format analyzers
: runs third party analyzers
Common options for all commands
--no-restore
: Doesn’t execute an implicit restore before formatting.--include-generated
: Format files generated by the SDK--include
: A list of relative file or folder paths to include in formatting. All files are formatted if empty.--exclude
: A list of relative file or folder paths to exclude from formatting.--verbosity
: Set the verbosity level. Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]--report
: Accepts a file path, which if provided, will produce a json report in the given directory.--binarylog
: Log all project or solution load information to a binary log file.--verify-no-changes
: Verify no formatting changes would be performed. Terminates with a non-zero exit code if any files would have been formatted.
Unique options for dotnet format
note, this is equivalent to dotnet format <project or solution> --fix-whitespace --fix-style <severity> --fix-analyzers <severity> --diagnostics <diagnostics>
in the global tool today.
Note: if the user specifies a severity here it is used for both style and analyzers.
Unique options for dotnet format whitespace
note, this is equivalent to dotnet format <project or solution> --fix-whitespace
in the global tool today.
Unique options for dotnet format style
--severity
: The severity of diagnostics to fix. Allowed values are info, warn, and error.
note, this is equivalent to dotnet format <project or solution> --fix-style <severity>
in the global tool today.
Unique options for dotnet cleanup analyzers
--diagnostics
: A space separated list of diagnostic ids to use as a filter when fixing code style or 3rd party issues.--severity
: The severity of diagnostics to fix. Allowed values are info, warn, and error.
note, this is equivalent to dotnet format <project or solution> --fix-analyzers <severity> --diagnostics <diagnostics>
in the global tool today.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:34
- Comments:14 (4 by maintainers)
Top GitHub Comments
Even though I can run
dotnet format
without installing the tool usingmcr.microsoft.com/dotnet/sdk:6.0
as base, I still have this issue in my pipeline. I’m having to downgrade the image tomcr.microsoft.com/dotnet/sdk:6.0.102
in order to fix the issue without giving up on format validation at build.Small issue in case anyone else is experiencing it (not sure if it’s by design). If I have a specific version installed locally e.g.
dotnet tool install dotnet-format --version 5.1.225507
, the commanddotnet format
will run the global .NET 6 version. To get around this I now rundotnet tool run dotnet-format
.