How do I pass parameters to the installer in a Chocolatey package?

If you are passing to the native installer, please use --install-arguments and not --package-parameters.

https://chocolatey.org/docs/commands-install#options-and-switches

 --ia, --installargs, --installarguments, --install-arguments=VALUE
 InstallArguments - Install Arguments to pass to the native installer in 
   the package. Defaults to unspecified.

-o, --override, --overrideargs, --overridearguments, --override-arguments
 OverrideArguments - Should install arguments be used exclusively without 
   appending to current package passed arguments? Defaults to false.

 --params, --parameters, --pkgparameters, --packageparameters, --package-parameters=VALUE
 PackageParameters - Parameters to pass to the package. Defaults to 
   unspecified.

Additionally, you may want to explore the documentation on how to pass options and switches - https://chocolatey.org/docs/commands-reference#how-to-pass-options-switches:

  • Quote Values: When you need to quote an entire argument, such as when using spaces, please use a combination of double quotes and apostrophes ("'value'"). In cmd.exe you can just use double quotes ("value") but in powershell.exe you should use backticks ( `"value`") or apostrophes ('value'). Using the combination allows for both shells to work without issue, except for when the next section applies.
  • Pass quotes in arguments: When you need to pass quoted values to to something like a native installer, you are in for a world of fun. In cmd.exe you must pass it like this: -ia "/yo=""Spaces spaces""". In PowerShell.exe, you must pass it like this: -ia '/yo=""Spaces spaces""'. No other combination will work. In PowerShell.exe if you are on version v3+, you can try --% before -ia to just pass the args through as is, which means it should not require any special workarounds.

I found information on setting a value into a Choco package parameter quite hard to find!

choco install -h isn't much help.

As a simple example of setting a value for a package parameter (as opposed to an MSI parameter - which is quite different), here is a simple, workable example:

choco install python2 --package-parameters='"/InstallDir:D:\Python2"'

"/InstallDir" is documented as a package parameter for the "python2" Choco package.

Note that there are a few alias for "--package-parameters", the shortest being "--params" if you like to save typing.

Note also the use of colon, NOT "=", where the value is assigned.

If you need spaces in the value, surround the value with extra pairs of double quotes - i.e. four new characters required.

... I have asked on the Choco forums to improve the documentation.

Tags:

Chocolatey