bijx
bijx

Reputation: 59

Chocolatey ParamPackage is empty, even though the value is passed in debug mode

I am attempting to use Chocolatey to install an MSI package via Powershell. Following all the documentation and examples, my setup looks like this:

chocolateyinstall.ps1

$ErrorActionPreference = 'Stop';
$fileLocation = Join-Path $toolsDir 'installer.msi'

$pp = Get-PackageParameters

Write-Output ("Keys count is : ${pp}")

if (!$pp['defaultName']) { Write-Error "Please provide a default name"; exit -1; }

...

When I run this command: choco install .\st-installer.1.6.7.nupkg --force --params "'/defaultName:Bob'" the powershell throws my error:

ERROR: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Please provide a default name

However if I run the command with the -d switch, Powershell shows me: packageParameters: '/defaultName:',

What am I doing wrong here? I've tried every variation of quotations around the params, installation argument instead of param package. I don't know what else I can do.

Upvotes: 2

Views: 521

Answers (1)

codewario
codewario

Reputation: 21418

I've run into this before when testing packages locally, where my additional parameter values aren't referenced like you're seeing. I don't know why it happens, but don't reference a hard path to the nupkg. Instead, set the source parameter to the directory the package is in (relative path is fine), and then install the package by it's package ID as though you were installing from Chocolatey.org. For example, if the package is in your current directory:

cinst -y st-installer --params "'/defaultName:Bob'" -s .

I'm not sure what version of Chocolatey you're on but if I try installing a package by pointing to the nupkg on disk, I get a warning about preferring the -s parameter and package ID instead of referencing the package file.

Upvotes: 1

Related Questions