Two new tasks have been added to allow the execution of the dotnet-format tool.
This will be executed as part as the AnalyzeTask, and by default, no changes will be made to any source files, i.e. run the --check option. A report will be generated in the TestResults folder.
An additional Task, Run-DotNetFormat, which can be executed to actually perform the fixups that were found.
There is a top level parameter, shouldRunDotNetFormat, which can be used to control whether this check task runs. This can be set within the recipe.cake file, and as a command line option. This isn't set on the Run-DotNetFormat task, since this task has to be run directly, therefore you are explicitly opting in to run that task, so no additional criteria is required.
Motivation and Context
This is part of the on-going work to increase the maintainability of our various codebases.
Testing
Clone this repository locally and checkout this PR branch
Copy the contents of the Chocolatey.Cake.Recipe/Content folder to the tools/Chocolatye.Cake.Recipe.0.24.0 folder in the chocolatey/choco repository
At the command line for that repository, run the following .\build.bat --shouldRunIlMerge=false --shouldRuntests=false --shouldRunInspectCode=false --shouldRunChocolatey=false --verbosity=diagnostic
In the output verify that a new Task Run-DotNetFormatCheck was executed, and that a new file dotnet-format.json was created in the code_drop/TestResults folder. No files should have been modified by running this
Run the following command .\build.bat --target=Run-DotNetFormat --verbosity=diagnostic
Verify again that the output file has been created, and also that a number of files have been changed with the required formatting changes. The changes to these files can be reverted.
Operating Systems Testing
N/A
Change Types Made
[ ] Bug fix (non-breaking change).
[x] Feature / Enhancement (non-breaking change).
[ ] Breaking change (fix or feature that could cause existing functionality to change).
Description Of Changes
Two new tasks have been added to allow the execution of the
dotnet-format
tool.This will be executed as part as the AnalyzeTask, and by default, no changes will be made to any source files, i.e. run the --check option. A report will be generated in the TestResults folder.
An additional Task, Run-DotNetFormat, which can be executed to actually perform the fixups that were found.
There is a top level parameter, shouldRunDotNetFormat, which can be used to control whether this check task runs. This can be set within the recipe.cake file, and as a command line option. This isn't set on the Run-DotNetFormat task, since this task has to be run directly, therefore you are explicitly opting in to run that task, so no additional criteria is required.
Motivation and Context
This is part of the on-going work to increase the maintainability of our various codebases.
Testing
Chocolatey.Cake.Recipe/Content
folder to thetools/Chocolatye.Cake.Recipe.0.24.0
folder in the chocolatey/choco repository.\build.bat --shouldRunIlMerge=false --shouldRuntests=false --shouldRunInspectCode=false --shouldRunChocolatey=false --verbosity=diagnostic
Run-DotNetFormatCheck
was executed, and that a new filedotnet-format.json
was created in thecode_drop/TestResults
folder. No files should have been modified by running this.\build.bat --target=Run-DotNetFormat --verbosity=diagnostic
Operating Systems Testing
N/A
Change Types Made
Change Checklist
Related Issue
Fixes #120