Skip to content

Commit

Permalink
(GH-1284) Install-ChocolateyPackage aliases File/File64
Browse files Browse the repository at this point in the history
When passing File and FileType to Install-ChocolateyPackage, it can
cause the following issue to occur:

~~~
ERROR: Cannot bind parameter because parameter 'fileType' is specified
more than once. To provide multiple values to parameters that can
accept multiple values, use the array syntax. For example, "-parameter
value1,value2,value3".
~~~

This is well documented at
https://github.com/chocolatey/choco/wiki/Troubleshooting#error-cannot-bind-parameter-because-parameter-filetype-is-specified-more-than-once
:

~~~powershell
$toolsPath      = $(Split-Path -parent
$MyInvocation.MyCommand.Definition)

$packageArgs = @{
  packageName   = 'test'
  fileType      = 'MSI'
  file          = "$toolsPath\somefile.msi"
  softwareName  = 'test'
  silentArgs    = '/qn /norestart'
  validExitCodes= @(0)
}

Install-ChocolateyPackage @packageArgs
was meant to be used in this scenario
~~~

`Install-ChocolateyPackage` doesn't have both a `File` parameter and a
`FileType` parameter. PowerShell has a "feature" where it does partial
matching of parameters. When you splat the parameters in, it tries to
apply both `File` and `FileType` to `FileType` and throws the above
error. Correct this behavior by setting aliases
  • Loading branch information
ferventcoder committed May 7, 2017
1 parent 73b7035 commit 7bd2a39
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ a 32 bit installation on a 64 bit system.
Prefer HTTPS when available. Can be HTTP, FTP, or File URIs.
In 0.10.6+, `File` and `FileFullPath` are aliases for Url. These
aliases, if used in earlier versions of Chocolatey, produce `ERROR:
Cannot bind parameter because parameter 'fileType' is specified more
than once.` See https://github.com/chocolatey/choco/issues/1284. Do not
use these aliases with the community package repository until 2018.
.PARAMETER Url64bit
OPTIONAL - If there is a 64 bit resource available, use this
parameter. Chocolatey will automatically determine if the user is
Expand All @@ -102,6 +108,13 @@ this parameter.
Prefer HTTPS when available. Can be HTTP, FTP, or File URIs.
In 0.10.6+, `File64` and `FileFullPath64` are aliases for Url64Bit.
These aliases, if used in earlier versions of Chocolatey, produce
`ERROR: Cannot bind parameter because parameter 'fileType' is specified
more than once.` See https://github.com/chocolatey/choco/issues/1284.
Do not use these aliases with the community package repository until
2018.
.PARAMETER ValidExitCodes
Array of exit codes indicating success. Defaults to `@(0)`.
Expand Down Expand Up @@ -261,9 +274,9 @@ param(
[parameter(Mandatory=$false, Position=1)]
[alias("installerType","installType")][string] $fileType = 'exe',
[parameter(Mandatory=$false, Position=2)][string[]] $silentArgs = '',
[parameter(Mandatory=$false, Position=3)][string] $url = '',
[alias("file","fileFullPath")][parameter(Mandatory=$false, Position=3)][string] $url = '',
[parameter(Mandatory=$false, Position=4)]
[alias("url64")][string] $url64bit = '',
[alias("url64","file64","fileFullPath64")][string] $url64bit = '',
[parameter(Mandatory=$false)] $validExitCodes = @(0),
[parameter(Mandatory=$false)][string] $checksum = '',
[parameter(Mandatory=$false)][string] $checksumType = '',
Expand Down

0 comments on commit 7bd2a39

Please sign in to comment.