From 7bd2a3976eec0237b08ab2d879c7fd339607e97b Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Sun, 7 May 2017 15:33:11 -0500 Subject: [PATCH] (GH-1284) Install-ChocolateyPackage aliases File/File64 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 --- .../functions/Install-ChocolateyPackage.ps1 | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 b/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 index 7578dcdbbb..294dcf2ca1 100644 --- a/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 +++ b/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 @@ -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 @@ -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)`. @@ -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 = '',