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

Run-PSScriptAnalyzer step fails if there are no Module or Script files to analyze #142

Closed Windos closed 2 months ago

Windos commented 3 months ago

Checklist

What You Are Seeing?

When running a build using this recipe with the Run-PSScriptAnalyzer step enabled, the build fails if the project being built happens to not have any module or script files to analyze.

The error message is: Cannot validate argument on parameter 'Path'. The argument is null. Provide a valid value for the argument, and then try running the command again.

What is Expected?

This step should gracefully skip analysis of script or module files if there are none to analyze, outputting this fact to the console.

How Did You Get This To Happen?

  1. Bump project (specifically Chocolatey GUI Licensed) to Chocolatey.Cake.Recipe 0.26.3
  2. Run the build (build.bat --verbosity=diagnostic --target=CI --testExecutionType=unit --shouldRunOpenCover=false)
  3. See the build fail with the message Cannot validate argument on parameter 'Path'. The argument is null. Provide a valid value for the argument, and then try running the command again.

System Details

Non-production TeamCity server

Installed Packages

N/A

Output Log

23:52:58       ========================================
23:52:58       Run-PSScriptAnalyzer
23:52:58       ========================================
23:52:58       Executing: &"C:/buildAgent/work/e281d7b6ca240c5/tools/Chocolatey.Cake.Recipe.0.26.3/Content/install-module.ps1" -ModuleName PSScriptAnalyzer -RequiredVersion 1.21.0
23:52:59       Install Module PSScriptAnalyzer with version 1.21.0...
23:53:41       Executing: &"C:/buildAgent/work/e281d7b6ca240c5/tools/Chocolatey.Cake.Recipe.0.26.3/Content/install-module.ps1" -ModuleName ConvertToSARIF -RequiredVersion 1.0.0
23:53:41       Install Module ConvertToSARIF with version 1.0.0...
23:53:50       There are no PSScriptAnalyzer Settings defined for this build, running with default format checking settings.
23:53:50       Executing: &"C:/buildAgent/work/e281d7b6ca240c5/tools/Chocolatey.Cake.Recipe.0.26.3/Content/run-psscriptanalyzer.ps1" -AnalyzePath "C:/buildAgent/work/e281d7b6ca240c5" -SettingsPath "C:/buildAgent/work/e281d7b6ca240c5/tools/Chocolatey.Cake.Recipe.0.26.3/Content/formatting-settings.psd1" -OutputPath "C:/buildAgent/work/e281d7b6ca240c5/code_drop/TestResults/PSScriptAnalyzer" -ExcludePaths tools, code_drop, src\*\bin\Debug, Source\*\bin\Debug, src\*\bin\Release, Source\*\bin\Release, src\packages, Source\packages
23:53:51       The 'Microsoft.PowerShell.Management' module was not imported because the 'Microsoft.PowerShell.Management' snap-in was already imported.
23:53:51       The 'Microsoft.PowerShell.Utility' module was not imported because the 'Microsoft.PowerShell.Utility' snap-in was already imported.
23:53:51       Analyzing module files...
23:53:53       Cannot validate argument on parameter 'Path'. The argument is null. Provide a valid value for the argument, and then try running the command again.
23:53:53       No rule violations found in Module Files.
23:53:53       Analyzing script files...
23:53:55       Violations found in Script Files...

[clipped]

Additional Context

N/A

choco-bot commented 2 months ago

:tada: This issue has been resolved in version 0.26.4 :tada:

The release is available on:

Your GitReleaseManager bot :package: :rocket: