Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install-ChocolateyPackage and other functions should alias File/File64 #1284

Closed
ferventcoder opened this issue May 7, 2017 · 2 comments
Closed
Assignees
Milestone

Comments

@ferventcoder
Copy link
Member

ferventcoder commented May 7, 2017

Add these aliases to Install-ChocolateyVsixPackage and Install-ChocolateyZipPackage as well.

Issue

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 :

$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
#Install-ChocolateyInstallPackage @packageArgs # this is likely what 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. We've already researched and there is no way to shut it off in PowerShell itself.

Not For Use With Community Packages Until January 2018

NOTE: Some features come out, but are not immediately available for use with the community package repository - this is one of them. While this is now available, it will not be recommended for wider use in the community package repository for six months as it will cause errors in earlier versions of Chocolatey.

References

@ferventcoder ferventcoder added this to the 0.10.6 milestone May 7, 2017
@ferventcoder ferventcoder self-assigned this May 7, 2017
@ferventcoder
Copy link
Member Author

NOTE: While this is now available, it will not be recommended for wider use (in the community package repository) for six months as it will cause errors in earlier versions of Chocolatey.

@AdmiringWorm
Copy link
Member

@ferventcoder while it's not recommended, is it allowed?
I'm thinking from a moderators perspective of whether we should push the package back and request them to remove the file/file64 parameter?

ferventcoder added a commit that referenced this issue May 18, 2017
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
ferventcoder added a commit to ferventcoder/choco that referenced this issue May 18, 2017
* stable:
  Remove duplicate word
  (chocolateyGH-1285) Default push to new or old w/warning
  (chocolateyGH-1285) Add old/new default push source
  (chocolateyGH-1298) GenericRunner.count() sets security protocol
  (chocolateyGH-1298) GenericRunner.list() should match run()
  (maint) API - Warn on extraction errors
  (chocolateyGH-389) API - Ensure ChocolateyInstall env var
  (maint) Do not load config back into global
  (chocolateyGH-1296) API - Reuse existing base configuration
  (maint) API - Note methods that won't allow changes
  (chocolateyGH-1294) API - Expose container directly
  (build) option to build debug version
  (doc) Source/Key notes surrounding source/apikey
  (maint) log that license file has been found
  (chocolateyGH-1287) Non-internal SimpleInjector XML Comments
  (maint) formatting
  (chocolateyGH-1287) API - Ensure dll can work w/licensed code
  (chocolateyGH-1284) Install-ChocolateyPackage aliases File/File64
@ferventcoder ferventcoder changed the title Install-ChocolateyPackage should alias File/File64 Install-ChocolateyPackage and other functions should alias File/File64 May 24, 2017
ferventcoder added a commit that referenced this issue May 29, 2017
With `Install-ChocolateyVsixPackage` and
`Install-Chocolatey-ZipPackage`, ensure that file / filefullpath are
aliases for urls (and the 64bit variants).
ferventcoder added a commit that referenced this issue May 29, 2017
* pr1264: (26 commits)
  (maint) COMMITTERS - EOL change to CRLF
  (doc) update CONTRIBUTING/COMMITTERS
  (GH-1241) XmlService - trace logging information
  (maint) formatting
  (GH-1241) FileSystem - move file creates directory
  (GH-1241) Explicitly handle closing
  (maint) formatting
  (GH-1292) Ensure manifest extracted on unpackself
  (log) replace_file use new lines for log
  (maint) update CHANGELOG / nuspec
  (maint) nuspec - add info links to description
  (maint) clean up lib nuspec
  (GH-1311) Install-ChocolateyPowershellCommand File/FileFullPath aliases
  (GH-1284) ensure file/filefullpath on functions
  (maint) ReadMe updates
  (GH-1241) Use process id with update file
  (maint) restrict list start/end messages to log file
  (GH-1309) Restrict trace output
  (GH-1241) More Robust File.Replace
  (GH-1241) Use write_file for stream writing
  ...
ferventcoder added a commit that referenced this issue May 29, 2017
* stable: (26 commits)
  (maint) COMMITTERS - EOL change to CRLF
  (doc) update CONTRIBUTING/COMMITTERS
  (GH-1241) XmlService - trace logging information
  (maint) formatting
  (GH-1241) FileSystem - move file creates directory
  (GH-1241) Explicitly handle closing
  (maint) formatting
  (GH-1292) Ensure manifest extracted on unpackself
  (log) replace_file use new lines for log
  (maint) update CHANGELOG / nuspec
  (maint) nuspec - add info links to description
  (maint) clean up lib nuspec
  (GH-1311) Install-ChocolateyPowershellCommand File/FileFullPath
aliases
  (GH-1284) ensure file/filefullpath on functions
  (maint) ReadMe updates
  (GH-1241) Use process id with update file
  (maint) restrict list start/end messages to log file
  (GH-1309) Restrict trace output
  (GH-1241) More Robust File.Replace
  (GH-1241) Use write_file for stream writing
  ...

# Conflicts:
#	CONTRIBUTING.md
#	README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants