chocolatey / Chocolatey.Cake.Recipe

A set of convention based Cake scripts for building Chocolatey projects
Apache License 2.0
5 stars 9 forks source link

(#120) Add ability to run dotnet-format #121

Closed gep13 closed 10 months ago

gep13 commented 10 months ago

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

  1. Clone this repository locally and checkout this PR branch
  2. 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
  3. At the command line for that repository, run the following .\build.bat --shouldRunIlMerge=false --shouldRuntests=false --shouldRunInspectCode=false --shouldRunChocolatey=false --verbosity=diagnostic
  4. 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
  5. Run the following command .\build.bat --target=Run-DotNetFormat --verbosity=diagnostic
  6. 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

Change Checklist

Related Issue

Fixes #120