dotnet-format - Man Page

Formats code to match editorconfig settings.

dotnet format

This article applies to: ✔️ .NET 6.x SDK and later versions

Synopsis

dotnet format [options] [<PROJECT | SOLUTION>]

dotnet format -h|--help

Description

dotnet format is a code formatter that applies style preferences to a project or solution. Preferences will be read from an .editorconfig file, if present, otherwise a default set of preferences will be used. For more information, see the EditorConfig documentation.

Arguments

PROJECT | SOLUTION

The MSBuild project or solution to run code formatting on. If a project or solution file is not specified, MSBuild searches the current working directory for a file that has a file extension that ends in proj or sln, and uses that file.

Options

None of the options below are required for the dotnet format command to succeed but can be used to further customize what is formatted and by which rules.

Subcommands

Whitespace

dotnet format whitespace - Formats code to match editorconfig settings for whitespace.

Description

The dotnet format whitespace subcommand will only run formatting rules associated with whitespace formatting. For a complete list of possible formatting options that you can specify in your .editorconfig file, see the whitespace formatting documentation.

Style

dotnet format style - Formats code to match EditorConfig settings for code style.

Description

The dotnet format style subcommand will only run formatting rule associated with code style formatting. For a complete list of possible formatting options that you can specify in your editorconfig file see the code style documentation.

Options

Analyzers

dotnet format analyzers - Formats code to match editorconfig settings for analyzers.

Description

The dotnet format analyzers subcommand will only run formatting rule associated with analyzers. For a list of possible analyzer rules that you can specify in your editorconfig file see the list of ids for code-analysis quality rules.

Options

Examples

Info

.NET