dotnet-format(1)

πŸ“¦
version 11.0.0~rc3 Β· 6 versions
, in alpine 3.24, centos-stream 10, centos-stream 9, fedora 43, fedora 44, nixpkgs unstable, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– dotnet-format(1) πŸ’–

the .NET Documentation girlies present… the dotnet format glow-up ✨

This article applies to: βœ”οΈ .NET 6 SDK and later versions

✨ NAME ✨

dotnet-format β€” formats code to match editorconfig settings. that's it, that's the job, and it slays πŸ’…


🌈 SYNOPSIS 🌈

dotnet format [<PROJECT | SOLUTION>]
  [--binarylog <BINARY-LOG-PATH>] [--diagnostics <DIAGNOSTICS>]
  [--exclude <EXCLUDE>] [--exclude-diagnostics <EXCLUDE-DIAGNOSTICS>]
  [--include <INCLUDE>] [--include-generated]
  [--no-restore] [--report <REPORT-PATH>] [--severity <LEVEL>]
  [-v|--verbosity <LEVEL>] [--verify-no-changes] [--version]

dotnet format -h|--help

πŸ¦‹ DESCRIPTION πŸ¦‹

okay bestie, so dotnet format is a code formatter that takes your style preferences and your static analysis recommendations and applies them to a project or a solution. it's giving personal stylist but for your codebase πŸ‘‘

Where do the preferences come from? From an .editorconfig file, if there is one present. And if there's not? No stress β€” a default set of preferences gets used instead. For more information, see the EditorConfig documentation. πŸ“š


πŸŽ€ ARGUMENTS πŸŽ€

  • PROJECT | SOLUTION β€” the MSBuild project or solution you wanna run code formatting on. and if you don't specify a project or solution file at all? MSBuild goes snooping around the current working directory for a file whose extension ends in proj or sln, and uses that one. lowkey it finds its own vibe πŸ”

πŸ’… OPTIONS πŸ’…

None of the options below are required for the dotnet format command to succeed β€” she works without them, fr fr. But you can use them to further customize what gets formatted and by which rules. main character customization energy ✨

  • --binarylog <BINARY-LOG-PATH> β€” logs all project or solution load information to a binary log file.
  • --diagnostics <DIAGNOSTICS> β€” a space-separated list of diagnostic IDs to use as a filter when fixing code style or third-party issues. default value is whichever IDs are listed in the .editorconfig file. for a list of built-in analyzer rule IDs that you can specify, see the list of IDs for code-analysis style rules.
  • --exclude <EXCLUDE> β€” a space-separated list of relative file or folder paths to exclude from formatting. the default is none.
  • --exclude-diagnostics <EXCLUDE-DIAGNOSTICS> β€” a space-separated list of diagnostic IDs to exclude when fixing code style or third-party issues. default value is none. for a list of built-in analyzer rule IDs that you can specify, see the list of IDs for code-analysis style rules.
  • --include <INCLUDE> β€” a space-separated list of relative file or folder paths to include in formatting. the default is all files in the solution or project.
  • --include-generated β€” formats files generated by the SDK.
  • --no-restore β€” doesn't execute an implicit restore before formatting. default is to do implicit restore.
  • --report <REPORT-PATH> β€” produces a JSON report in the directory specified by <REPORT_PATH>.
  • --severity <LEVEL> β€” the minimum severity of diagnostics to fix. allowed values are info, warn, and error. the default value is warn.
  • --verify-no-changes β€” verifies that no formatting changes would be performed. terminates with a non zero exit code if any files would have been formatted. πŸ’€ she's checking your work, be brave
  • --version β€” displays version information.
  • -v|--verbosity <LEVEL> β€” sets the verbosity level of the command. allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]. for more information, see <xref:Microsoft.Build.Framework.LoggerVerbosity>.
  • -?|-h|--help β€” prints out a description of how to use the command.

🌸 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

  • --folder β€” treat the <PROJECT | SOLUTION> argument as a path to a simple folder of code files.

⭐ 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

  • --diagnostics <DIAGNOSTICS> β€” a space-separated list of diagnostic IDs to use as a filter when fixing code style issues. default value is whichever IDs are listed in the .editorconfig file. for a list of built-in code style analyzer rule IDs that you can specify, see the list of IDs for code-analysis style rules.
  • --severity <LEVEL> β€” the minimum severity of diagnostics to fix. allowed values are info, warn, and error. the default value is warn

πŸ”₯ 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

  • --diagnostics <DIAGNOSTICS> β€” a space-separated list of diagnostic IDs to use as a filter when fixing non code style issues. default value is whichever IDs are listed in the .editorconfig file. for a list of built-in analyzer rule IDs that you can specify, see the list of IDs for quality rules. for third-party analyzers refer to their documentation.
  • --severity <LEVEL> β€” the minimum severity of diagnostics to fix. allowed values are info, warn, and error. the default value is warn.

🌟 EXAMPLES 🌟

  • Format all code in the solution:
dotnet format ./solution.sln
  • Clean up all code in the application project:
dotnet format ./src/application.csproj
  • Verify that all code is correctly formatted:
dotnet format --verify-no-changes
  • Clean up all code in the src and tests directory but not in src/submodule-a:
dotnet format --include ./src/ ./tests/ --exclude ./src/submodule-a/
  • Fix a specific code style issue:
dotnet format style --diagnostics IDE0005 --severity info
  • Fix all code style issues that have severity info, warning or error:
dotnet format style --severity info
  • Fix a specific (non code style) analyzer issue:
dotnet format analyzers --diagnostics CA1831 --severity warn
  • Fix all non code style issues that have severity info, warning or error:
dotnet format analyzers --severity info

and that's the whole page, bestie!! ✨ this one's from the .NET Documentation, dated 2025-10-30, and yeah the manual name is literally dotnet-format(1) β€” go format something pretty, you got this πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from