Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use custom parameters in chocolatey '.config' file?

Tags:

chocolatey

I use chocolatey to install git with parameters and that works fine in command-line:

choco install git -params '"/GitOnlyOnPath /NoAutoCrlf"'

Now, I want to put that in my .config file, where it does not seem to work. Here is an example of how I would expect to configure it:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="git" params="/GitOnlyOnPath /NoAutoCrlf"/>
</packages>

This would install git successfully, but ignore the arguments: autocrlf is still true afterwards.

The documentation and most sources only cover the version and location attributes for package-entities. So, (how) is it possible, to configure custom parameters inside a .config file?

like image 760
SevenEleven Avatar asked Dec 05 '15 14:12

SevenEleven


People also ask

What is Cinst?

cinst (Shortcut for choco install) cpush (Shortcut for choco push) cuninst (Shortcut for choco uninstall) cup (Shortcut for choco upgrade)


2 Answers

I'm not quite sure I agree with your argument that the documentation doesn't cover this, but maybe perhaps that it is hard to find? We have it under the install article as that is where you would call a packages.config.

https://docs.chocolatey.org/en-us/choco/commands/install#packages.config

Included here:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="apackage" />
  <package id="anotherPackage" version="1.1" />
  <package id="chocolateytestpackage" version="0.1" source="somelocation" />
  <package id="alloptions" version="0.1.1"
           source="https://somewhere/api/v2/" installArguments=""
           packageParameters="" forceX86="false" allowMultipleVersions="false"
           ignoreDependencies="false"
           />
</packages>

Always try to check the documentation in the choco wiki - it's the most up-to-date. Plus the Chocolatey packages.config is not like the NuGet packages.config.

like image 111
ferventcoder Avatar answered Sep 19 '22 19:09

ferventcoder


I totally agree with others that the documentation does not cover this important matter sufficiently. There is no example of its syntax of the fact the --params switch is equivalent to packageParameters attributes.

Here is an example of how to store params on the config file.

<?xml version="1.0" encoding="utf-8"?>
<packages>
       <package id="apache-httpd" packageParameters='/installLocation="D:\server\httpd"'/>
</packages>

Notice to the attribute name and its format.

Other similar tools use JSON format to store packages lists (PHP composer, NPM & ...) that is way more intuitive.

like image 42
Handsome Nerd Avatar answered Sep 19 '22 19:09

Handsome Nerd