官方github:GitHub - dotnet/format: Home for the dotnet-format command
1,安装 dotnet tool install -g dotnet-format
2,语法
Usage:
dotnet-format [options] [<workspace>]
Arguments:
<workspace> A path to a solution file, a project file, or a folder containing a solution or project file. If a path is not specified then the current directory is used.
Options:
--no-restore Doesn't execute an implicit restore before formatting.
--folder, -f Whether to treat the `<workspace>` argument as a simple folder of files.
--fix-whitespace, -w Run whitespace formatting. Run by default when not applying fixes.
--fix-style, -s <severity> Run code style analyzers and apply fixes.
--fix-analyzers, -a <severity> Run 3rd party analyzers and apply fixes.
--diagnostics <diagnostic ids> A space separated list of diagnostic ids to use as a filter when fixing code style or 3rd party analyzers.
--include <include> A list of relative file or folder paths to include in formatting. All files are formatted if empty.
--exclude <exclude> A list of relative file or folder paths to exclude from formatting.
--check Formats files without saving changes to disk. Terminates with a non-zero exit code if any files were formatted.
--report <report> Accepts a file path, which if provided, will produce a json report in the given directory.
--binarylog <binary-log-path> Log all project or solution load information to a binary log file.
--verbosity, -v <verbosity> Set the verbosity level. Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]
--version Show version information
3,实测
4,github自动格式化办法 参考链接: dotnet 基于 dotnet format 的 GitHub Action 自动代码格式化机器人
更多信息请关注公众号: