CPMR0016 - Script Contains Usage of Installation Arguments (script)

CPMR0016 - Script Contains Usage of Installation Arguments (script)

:choco-warning: WARNING

This rule has been marked as a Requirement.

Requirements represent the minimum quality of a package that is acceptable. When a package version has failed requirements, the package version requires fixing and/or response by the maintainer. Provided a Requirement has flagged correctly, it must be fixed before the package version can be approved. The exact same version should be uploaded during moderation review.

Issue

In an automation script (.ps1/.psm1), the use of chocolateyInstallArguments was found.

The package should instead use package parameters - see How to Parse Package Parameters and an example package to review for how to add information to the description would be the Git package.

Reasoning

InstallArguments is meant to be a transparent variable that is passed right to a Chocolatey install helper function. If it is called in the script it could be misused or changed. Therefore we don't allow it in scripts.

Another pattern:

$installArguments = $env:chocolateyInstallArguments
if ([string]::IsNullOrEmpty($installArguments )) {
  $installArguments = " /Q /IAcceptSQLServerLicenseTerms /ACTION=install /INSTANCEID=SQLEXPRESS /INSTANCENAME=SQLEXPRESS /UPDATEENABLED=FALSE "
}

This behavior is unnecessary as Chocolatey already does this in the background. All you need to do in the script is set the install arguments.

$installArguments = " /Q /IAcceptSQLServerLicenseTerms /ACTION=install /INSTANCEID=SQLEXPRESS /INSTANCENAME=SQLEXPRESS /UPDATEENABLED=FALSE "

The consumer will decide to override install arguments or append to the current set with --install-arguments/--ia and --override-arguments/-o, see the install command docs