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 [<PROJECT | SOLUTION>] [command] [options]

dotnet format -h|--help

Description

dotnet format is a code formatter that applies style preferences and static analysis recommendations 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 you can use them 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 only runs formatting rules associated with whitespace formatting. For a complete list of possible formatting options that you can specify in your .editorconfig file, see the C# formatting options.

Options

Style

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

Description

The dotnet format style subcommand only runs formatting rules associated with code style formatting. For a complete list of formatting options that you can specify in your editorconfig file, see Code style rules.

Options

Analyzers

dotnet format analyzers - Formats code to match editorconfig settings for analyzers (excluding code style rules).

Description

The dotnet format analyzers subcommand only runs formatting rules associated with analyzers. For a list of analyzer rules that you can specify in your editorconfig file, see Quality rules.

Options

Examples

Info

2024-10-02 .NET Documentation