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

2

14

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?

Tuberosity answered 5/12, 2015 at 14:34 Comment(0)
T
14

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.

Tramline answered 5/12, 2015 at 22:14 Comment(6)
Thank you, that's exactly what I've been looking for! Yes, I somehow missed that. Maybe because I mainly searched for params only instead of packageParameters.Tuberosity
I'd say the documentation doesn't really adequately cover this. For example, while ignoreDependencies seems like it should work, ignoreChecksum(s) doesn't in my experience, and there's no documentation about which of those switches should be expected to work and which should not.Nicky
@Nicky I believe you are correct. As we've added new items we haven't really kept what can go in the config up to date. Right now it's all you see in that last example in the packages.config above and on the site.Tramline
What is the format of the packageParameters field? Would it be packageParameters="/group" or packageParameters="group"?Supplication
This is a great resource to bookmark - chocolatey.org/docs/how-to-parse-package-parameters-argumentTramline
This package parameter worked for us: <package id="irfanview" packageParameters="/group"/>Supplication
C
3

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.

Comedietta answered 23/11, 2019 at 0:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.