Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

chocolatey

I created a package from an MSI. However, I need to pass in custom parameters.

/i SERVER='xx.yyy.com

Here are the few things I tried by reading the choco command spec, but none worked.

> choco install foo -y --params "SERVER='xx.yyy.com'"
> choco install foo -y --params "SERVER=xx.yyy.com"
> choco install foo -y --params "SERVER= xx.yyy.com"

How do I pass the install options to the installer?

like image 340
Raghav Avatar asked Jun 14 '16 05:06

Raghav


People also ask

How do you use Chocolatey package manager?

Getting Chocolatey onto your system is very simple since the commands can be copied and pasted into your command prompt from Chocolatey.org. To start, you need to open an elevated command prompt. To open an elevated Command Prompt, right-click on the Command Prompt launcher and select Run as Administrator.

Where does Chocolatey install packages?

Chocolatey packages are installed to ChocolateyInstall\lib , but the software could go to various locations, depending on how the package maintainer created the package. Some packages are installed under ChocolateyInstall\lib , others - especially packages that are based on Windows installers (.


2 Answers

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.
like image 171
ferventcoder Avatar answered Sep 28 '22 13:09

ferventcoder


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.

like image 40
spechter Avatar answered Sep 28 '22 14:09

spechter