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

(#142) Skip PSSA analysis when there are no files (Script or Module) to analyze #143

Closed Windos closed 2 months ago

Windos commented 3 months ago

Description Of Changes

This PR adds a check to determine if there are any Module or Script files to be analyzed before proceeding to attempt to pass a potentially NULL variable to PSScriptAnalyzer.

Motivation and Context

The Chocolatey GUI Licensed project includes script files but not modules files which was causing it's build to fail due to the resulting attempt to analyze a NULL path resulting in 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.

Testing

This has been tested on a non-production build agent by manually editing the run-psscriptanalyzer.ps1 script and re-running the build.

Operating Systems Testing

Windows Server 2019

Change Types Made

Change Checklist

Related Issue

Fixes #142

gep13 commented 2 months ago

@Windos thank you for getting this fixed up!