Conditional dependencies best practice

36 Views Asked by At

I would like to create a Chocolatey package that, at installation time/in chocolateyInstall.ps1, installs a different Chocolatey package if a condition is met (in my specific case, if a boolean package parameter has been turned on). In code terms I want to do something like this:

# ChocolateyInstall.ps1 for package 'foo'
$pp = Get-PackageParameters

if ($pp['BarFuncs'] -eq 'true') { 
  # Install Chocolatey package 'bar' (1)
}

I know I can just do choco install -y bar at (1). In fact, I have tested this and it works. However, I am not sure this is OK to do and in general with tools like package managers it often isn't.

So is there any clean way to do this? I have found nothing in the reference.

I also don't think Chocolatey-InstallPackage is what I'm looking for, as that seems to be for installing files to %PROGRAMFILES% for the current package instead of installing a different Chocolatey package.

Thank you in advance!

0

There are 0 best solutions below