SevenEleven
SevenEleven

Reputation: 2474

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

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?

Upvotes: 14

Views: 9628

Answers (2)

ferventcoder
ferventcoder

Reputation: 12571

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.

Upvotes: 14

Real Dreams
Real Dreams

Reputation: 18010

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.

Upvotes: 3

Related Questions