Skip to content

Commit

Permalink
(GH-1323) File/File64 as params not aliases
Browse files Browse the repository at this point in the history
File and File64 were added as aliases to `Url`/`Url64bit` in 0.10.6 to
add compatibility, but they actually introduced more incompatibilities
instead of addressing them due to being aliases. Move them to
parameters and set the values if the original values are empty.

NOTE: This could still cause a small incompatibility if someone is
attempting to use both File and Url in a single set of package
parameters but apply it to multiple function calls. Fortunately it
typically means they will have filled out both items, which means those
functions should still continue to work as they have in the past.
  • Loading branch information
ferventcoder committed Jun 6, 2017
1 parent 587e8a2 commit a71767c
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 85 deletions.
52 changes: 34 additions & 18 deletions docs/generated/HelpersInstallChocolateyPackage.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Install-ChocolateyPackage `
[-Checksum64 <String>] `
[-ChecksumType64 <String>] `
[-Options <Hashtable>] `
[-File <String>] `
[-File64 <String>] `
[-UseOnlyPackageSilentArguments] `
[-UseOriginalLocation] `
[-IgnoredArguments <Object[]>] [<CommonParameters>]
Expand Down Expand Up @@ -211,16 +213,9 @@ 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 January
2018.

Property | Value
---------------------- | ------------------
Aliases | file, fileFullPath
---------------------- | -----
Aliases |
Required? | false
Position? | 4
Default Value |
Expand All @@ -237,16 +232,9 @@ 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
January 2018.

Property | Value
---------------------- | -----------------------------
Aliases | url64, file64, fileFullPath64
---------------------- | -----
Aliases | url64
Required? | false
Position? | 5
Default Value |
Expand Down Expand Up @@ -367,6 +355,34 @@ Position? | named
Default Value | @{Headers=@{}}
Accept Pipeline Input? | false

### -File [&lt;String&gt;]
Will be used for Url if Url is empty. Available in 0.10.7+.

This parameter provides compatibility, but should not be used directly
and not with the community package repository until January 2018.

Property | Value
---------------------- | ------------
Aliases | fileFullPath
Required? | false
Position? | named
Default Value |
Accept Pipeline Input? | false

### -File64 [&lt;String&gt;]
Will be used for Url64bit if Url64bit is empty. Available in 0.10.7+.

This parameter provides compatibility, but should not be used directly
and not with the community package repository until January 2018.

Property | Value
---------------------- | --------------
Aliases | fileFullPath64
Required? | false
Position? | named
Default Value |
Accept Pipeline Input? | false

### -UseOnlyPackageSilentArguments
Do not allow choco to provide/merge additional silent arguments and only
use the ones available with the package. Available in 0.9.10+.
Expand Down
26 changes: 17 additions & 9 deletions docs/generated/HelpersInstallChocolateyVsixPackage.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Install-ChocolateyVsixPackage `
[-Checksum <String>] `
[-ChecksumType <String>] `
[-Options <Hashtable>] `
[-File <String>] `
[-IgnoredArguments <Object[]>] [<CommonParameters>]
~~~

Expand Down Expand Up @@ -95,16 +96,9 @@ Prefer HTTPS when available. Can be HTTP, FTP, or File URIs.

In 0.10.4+, `Url` is an alias for VsixUrl.

In 0.10.6+, `File` and `FileFullPath` are aliases for VsixUrl. These
aliases, if used in earlier versions of Chocolatey, may 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 January
2018.

Property | Value
---------------------- | -----------------------
Aliases | url, file, fileFullPath
---------------------- | -----
Aliases | url
Required? | false
Position? | 2
Default Value |
Expand Down Expand Up @@ -189,6 +183,20 @@ Position? | named
Default Value | @{Headers=@{}}
Accept Pipeline Input? | false

### -File [&lt;String&gt;]
Will be used for VsixUrl if VsixUrl is empty. Available in 0.10.7+.

This parameter provides compatibility, but should not be used directly
and not with the community package repository until January 2018.

Property | Value
---------------------- | ------------
Aliases | fileFullPath
Required? | false
Position? | named
Default Value |
Accept Pipeline Input? | false

### -IgnoredArguments [&lt;Object[]&gt;]
Allows splatting with arguments that do not apply. Do not use directly.

Expand Down
52 changes: 34 additions & 18 deletions docs/generated/HelpersInstallChocolateyZipPackage.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Install-ChocolateyZipPackage `
[-Checksum64 <String>] `
[-ChecksumType64 <String>] `
[-Options <Hashtable>] `
[-File <String>] `
[-File64 <String>] `
[-IgnoredArguments <Object[]>] [<CommonParameters>]
~~~

Expand Down Expand Up @@ -102,16 +104,9 @@ 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, may 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 January
2018.

Property | Value
---------------------- | ------------------
Aliases | file, fileFullPath
---------------------- | -----
Aliases |
Required? | false
Position? | 2
Default Value |
Expand Down Expand Up @@ -142,16 +137,9 @@ 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, may 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
January 2018.

Property | Value
---------------------- | -----------------------------
Aliases | url64, file64, fileFullPath64
---------------------- | -----
Aliases | url64
Required? | false
Position? | 4
Default Value |
Expand Down Expand Up @@ -270,6 +258,34 @@ Position? | named
Default Value | @{Headers=@{}}
Accept Pipeline Input? | false

### -File [&lt;String&gt;]
Will be used for Url if Url is empty. Available in 0.10.7+.

This parameter provides compatibility, but should not be used directly
and not with the community package repository until January 2018.

Property | Value
---------------------- | ------------
Aliases | fileFullPath
Required? | false
Position? | named
Default Value |
Accept Pipeline Input? | false

### -File64 [&lt;String&gt;]
Will be used for Url64bit if Url64bit is empty. Available in 0.10.7+.

This parameter provides compatibility, but should not be used directly
and not with the community package repository until January 2018.

Property | Value
---------------------- | --------------
Aliases | fileFullPath64
Required? | false
Position? | named
Default Value |
Accept Pipeline Input? | false

### -IgnoredArguments [&lt;Object[]&gt;]
Allows splatting with arguments that do not apply. Do not use directly.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,6 @@ 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 January
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 @@ -109,13 +102,6 @@ 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
January 2018.
.PARAMETER ValidExitCodes
Array of exit codes indicating success. Defaults to `@(0)`.
Expand Down Expand Up @@ -183,6 +169,18 @@ The recommendation is to use at least SHA256.
.PARAMETER Options
OPTIONAL - Specify custom headers. Available in 0.9.10+.
.PARAMETER File
Will be used for Url if Url is empty. Available in 0.10.7+.
This parameter provides compatibility, but should not be used directly
and not with the community package repository until January 2018.
.PARAMETER File64
Will be used for Url64bit if Url64bit is empty. Available in 0.10.7+.
This parameter provides compatibility, but should not be used directly
and not with the community package repository until January 2018.
.PARAMETER UseOnlyPackageSilentArguments
Do not allow choco to provide/merge additional silent arguments and only
use the ones available with the package. Available in 0.9.10+.
Expand Down Expand Up @@ -275,15 +273,17 @@ param(
[parameter(Mandatory=$false, Position=1)]
[alias("installerType","installType")][string] $fileType = 'exe',
[parameter(Mandatory=$false, Position=2)][string[]] $silentArgs = '',
[alias("file","fileFullPath")][parameter(Mandatory=$false, Position=3)][string] $url = '',
[parameter(Mandatory=$false, Position=3)][string] $url = '',
[parameter(Mandatory=$false, Position=4)]
[alias("url64","file64","fileFullPath64")][string] $url64bit = '',
[alias("url64")][string] $url64bit = '',
[parameter(Mandatory=$false)] $validExitCodes = @(0),
[parameter(Mandatory=$false)][string] $checksum = '',
[parameter(Mandatory=$false)][string] $checksumType = '',
[parameter(Mandatory=$false)][string] $checksum64 = '',
[parameter(Mandatory=$false)][string] $checksumType64 = '',
[parameter(Mandatory=$false)][hashtable] $options = @{Headers=@{}},
[alias("fileFullPath")][parameter(Mandatory=$false)][string] $file = '',
[alias("fileFullPath64")][parameter(Mandatory=$false)][string] $file64 = '',
[parameter(Mandatory=$false)]
[alias("useOnlyPackageSilentArgs")][switch] $useOnlyPackageSilentArguments = $false,
[parameter(Mandatory=$false)][switch]$useOriginalLocation,
Expand All @@ -300,6 +300,13 @@ param(
if (![System.IO.Directory]::Exists($tempDir)) { [System.IO.Directory]::CreateDirectory($tempDir) | Out-Null }
$downloadFilePath = Join-Path $tempDir "$($packageName)Install.$fileType"

if ($url -eq '' -or $url -eq $null) {
$url = $file
}
if ($url64bit -eq '' -or $url64bit -eq $null) {
$url64bit = $file64
}

[string]$filePath = $downloadFilePath
if ($useOriginalLocation) {
$filePath = $url
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,6 @@ Prefer HTTPS when available. Can be HTTP, FTP, or File URIs.
In 0.10.4+, `Url` is an alias for VsixUrl.
In 0.10.6+, `File` and `FileFullPath` are aliases for VsixUrl. These
aliases, if used in earlier versions of Chocolatey, may 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 January
2018.
.PARAMETER VsVersion
The major version number of Visual Studio where the
package should be installed. This is optional. If not
Expand Down Expand Up @@ -108,6 +101,12 @@ The recommendation is to use at least SHA256.
.PARAMETER Options
OPTIONAL - Specify custom headers. Available in 0.9.10+.
.PARAMETER File
Will be used for VsixUrl if VsixUrl is empty. Available in 0.10.7+.
This parameter provides compatibility, but should not be used directly
and not with the community package repository until January 2018.
.PARAMETER IgnoredArguments
Allows splatting with arguments that do not apply. Do not use directly.
Expand Down Expand Up @@ -139,15 +138,21 @@ Install-ChocolateyZipPackage
#>
param(
[alias("name")][parameter(Mandatory=$true, Position=0)][string] $packageName,
[alias("url","file","fileFullPath")][parameter(Mandatory=$false, Position=1)][string] $vsixUrl,
[alias("url")][parameter(Mandatory=$false, Position=1)][string] $vsixUrl,
[alias("visualStudioVersion")][parameter(Mandatory=$false, Position=2)][int] $vsVersion = 0,
[parameter(Mandatory=$false)][string] $checksum = '',
[parameter(Mandatory=$false)][string] $checksumType = '',
[parameter(Mandatory=$false)][hashtable] $options = @{Headers=@{}},
[alias("fileFullPath")][parameter(Mandatory=$false)][string] $file = '',
[parameter(ValueFromRemainingArguments = $true)][Object[]] $ignoredArguments
)

Write-FunctionCallLogMessage -Invocation $MyInvocation -Parameters $PSBoundParameters

if ($vsixUrl -eq '' -or $vsixUrl -eq $null) {
$vsixUrl = $file
}

if($vsVersion -eq 0) {
if ([System.IntPtr]::Size -eq 4)
{
Expand Down
Loading

0 comments on commit a71767c

Please sign in to comment.