Skip to content

🎉🥳 dotnet-format is now part of the .NET 6 SDK #1268

@JoeRobich

Description

@JoeRobich

Starting 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 whitespace
  • dotnet format style: runs code style analyzers
  • dotnet 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions