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

Get-PackageParameters: force built-in method to be preferred over chocolatey-core.extension method #1476

Closed
deckjockey opened this issue Jan 23, 2018 · 8 comments

Comments

@deckjockey
Copy link

Expected Behavior

Get-PackageParameters function supports parameters with spaces:
For example `-Parameters "/ITEM1:value /ITEM2:value with spaces"
https://chocolatey.org/docs/helpers-get-package-parameters

Current Behavior

Get-PackageParameters function supports parameters with spaces:
For example `-Parameters "/ITEM1:value /ITEM2:value with spaces"
https://chocolatey.org/docs/helpers-get-package-parameters

Possible Solution

Should Get-PackageParameters.ps1 be removed from the chocolatey-core.extension package? since it is already a function in chocolatey base package

Steps to Reproduce (for bugs)

===========================================
Install package without Extensions package:

chocolatey 0.10.8

example:

choco install nabtrade-securities-wiki --params="'/SEINSTALL:D:\ccviews\Program Files\securitease_test1'" -y

Parameters with spaces work as expected:

2018-01-18 14:15:53,850 12728 [INFO ] - Chocolatey v0.10.8
2018-01-18 14:15:53,859 12728 [DEBUG] - Chocolatey is running on Windows v 6.1.7601.65536
2018-01-18 14:15:53,862 12728 [DEBUG] - Attempting to delete file "C:/ProgramData/chocolatey/choco.exe.old".
2018-01-18 14:15:53,864 12728 [DEBUG] - Attempting to delete file "C:\ProgramData\chocolatey\choco.exe.old".
2018-01-18 14:15:53,874 12728 [DEBUG] - Command line: "C:\ProgramData\chocolatey\choco.exe" install nabtrade-securities-wiki --params="'/SEINSTALL:D:\ccviews\Program Files\securitease_test1'" -y
2018-01-18 14:15:53,875 12728 [DEBUG] - Received arguments: install nabtrade-securities-wiki --params='/SEINSTALL:D:\ccviews\Program Files\securitease_test1' -y
...
PackageParameters='/SEINSTALL:D:\ccviews\Program Files\securitease_test1'|
...
2018-01-18 14:16:35,474 12728 [DEBUG] - Calling built-in PowerShell host with ['[System.Threading.Thread]::CurrentThread.CurrentCulture = '';[System.Threading.Thread]::CurrentThread.CurrentUICulture = ''; & import-module -name 'C:\ProgramData\chocolatey_test1\helpers\chocolateyInstaller.psm1'; & 'C:\ProgramData\chocolatey_test1\helpers\chocolateyScriptRunner.ps1' -packageScript 'C:\ProgramData\chocolatey_test1\lib\nabtrade-securities-wiki\tools\chocolateyInstall.ps1' -installArguments '' -packageParameters '/SEINSTALL:D:\ccviews\Program Files\securitease_test1'']
...
2018-01-18 14:16:38,082 12728 [DEBUG] - Running 'ChocolateyScriptRunner' for nabtrade-securities-wiki v05.26.00.00 with packageScript 'C:\ProgramData\chocolatey_test1\lib\nabtrade-securities-wiki\tools\chocolateyInstall.ps1', packageFolder:'C:\ProgramData\chocolatey_test1\lib\nabtrade-securities-wiki', installArguments: '', packageParameters: '/SEINSTALL:D:\ccviews\Program Files\securitease_test1',
...
2018-01-18 14:16:38,116 12728 [INFO ] - ================================================================================
2018-01-18 14:16:38,123 12728 [INFO ] - * Getting parameters...
2018-01-18 14:16:38,152 12728 [DEBUG] - Running Get-PackageParameters
2018-01-18 14:16:38,165 12728 [DEBUG] - Parsing $env:ChocolateyPackageParameters and $env:ChocolateyPackageParametersSensitive for parameters
2018-01-18 14:16:38,180 12728 [DEBUG] - Adding package param 'SEINSTALL'='D:\ccviews\Program Files\securitease_test1'
2018-01-18 14:16:38,215 12728 [INFO ] - -> SEINSTALL parameter = D:\ccviews\Program Files\securitease_test1
2018-01-18 14:16:38,221 12728 [INFO ] - ================================================================================

========================================
Install package with Extensions package:

chocolatey 0.10.8
chocolatey-core.extension 1.3.3

example:

choco install nabtrade-securities-wiki --params="'/SEINSTALL:D:\ccviews\Program Files\securitease_test1'" -y

Parameters with spaces no longer work:

2018-01-18 14:23:06,289 13400 [INFO ] - Chocolatey v0.10.8
2018-01-18 14:23:06,298 13400 [DEBUG] - Chocolatey is running on Windows v 6.1.7601.65536
2018-01-18 14:23:06,301 13400 [DEBUG] - Attempting to delete file "C:/ProgramData/chocolatey/choco.exe.old".
2018-01-18 14:23:06,302 13400 [DEBUG] - Attempting to delete file "C:\ProgramData\chocolatey\choco.exe.old".
2018-01-18 14:23:06,310 13400 [DEBUG] - Command line: "C:\ProgramData\chocolatey\choco.exe" install nabtrade-securities-wiki --params="'/SEINSTALL:D:\ccviews\Program Files\securitease_test1'" -y
2018-01-18 14:23:06,312 13400 [DEBUG] - Received arguments: install nabtrade-securities-wiki --params='/SEINSTALL:D:\ccviews\Program Files\securitease_test1' -y
...
PackageParameters='/SEINSTALL:D:\ccviews\Program Files\securitease_test1'|
...
2018-01-18 14:23:45,378 13400 [DEBUG] - Calling built-in PowerShell host with ['[System.Threading.Thread]::CurrentThread.CurrentCulture = '';[System.Threading.Thread]::CurrentThread.CurrentUICulture = ''; & import-module -name 'C:\ProgramData\chocolatey_test1\helpers\chocolateyInstaller.psm1'; & 'C:\ProgramData\chocolatey_test1\helpers\chocolateyScriptRunner.ps1' -packageScript 'C:\ProgramData\chocolatey_test1\lib\nabtrade-securities-wiki\tools\chocolateyInstall.ps1' -installArguments '' -packageParameters '/SEINSTALL:D:\ccviews\Program Files\securitease_test1'']
...
2018-01-18 14:23:48,253 13400 [DEBUG] - Running 'ChocolateyScriptRunner' for nabtrade-securities-wiki v05.26.00.00 with packageScript 'C:\ProgramData\chocolatey_test1\lib\nabtrade-securities-wiki\tools\chocolateyInstall.ps1', packageFolder:'C:\ProgramData\chocolatey_test1\lib\nabtrade-securities-wiki', installArguments: '', packageParameters: '/SEINSTALL:D:\ccviews\Program Files\securitease_test1',
...
2018-01-18 14:23:48,280 13400 [INFO ] - ================================================================================
2018-01-18 14:23:48,288 13400 [INFO ] - * Getting parameters...
2018-01-18 14:23:48,428 13400 [INFO ] - -> SEINSTALL parameter = D:\ccviews\Program
2018-01-18 14:23:48,442 13400 [INFO ] - ================================================================================
after.choco.summary.log
after.chocolatey.log
before.choco.summary.log
before.chocolatey.log
chocolateyInstall.zip

Context

Unable to use parameters with spaces after chocolatey-core.extension is installed, so is a show stopper

Your Environment

  • Package Version used: 1.3.3
  • Operating System and version: Windows v 6.1.7601.65536
  • Chocolatey version: Chocolatey v0.10.8
  • Install/uninstall gist:
@deckjockey
Copy link
Author

Refer to issue in Core-Extension, which they don't want to fix either: chocolatey-community/chocolatey-packages#950

@deckjockey
Copy link
Author

The syntax is different depending on whether the Extensions are install or not, which is bad, as you cannot assume the Extensions are installed if a package DOES NOT require them.

So with the extension installed, the following syntax works:

choco install nabtrade-securities-wiki --params="/SEINSTALL:'D:\ccviews\Program Files\securitease_test1'" -y

But without the extension, the same syntax fails:

choco install nabtrade-securities-wiki --params="/SEINSTALL:'D:\ccviews\Program Files\securitease_test1'" -y

Getting parameters...
-> SEINSTALL parameter = 'D:\ccviews\Program Files\securitease_test1'

Copy Wiki files to Securitease folder...
-> toolsDir = C:\ProgramData\chocolatey_test1\lib\nabtrade-securities-wiki\to
ols
ERROR: ERROR: Securitese Folder is missing!
The install of nabtrade-securities-wiki was NOT successful.
Error while running 'C:\ProgramData\chocolatey_test1\lib\nabtrade-securities-wik
i\tools\chocolateyInstall.ps1'.
See log for details.

@ferventcoder
Copy link
Member

ferventcoder commented Jan 23, 2018

@deckjockey The problem here is you are not passing the parameters correctly. If you use PowerShell.exe and you run choco --params="howdy how are you", what makes it to choco is --params=howdy how are you- notice what is missing?

We have a published way of passing options, please see https://chocolatey.org/docs/commands-reference#how-to-pass-options-switches

@deckjockey
Copy link
Author

Hi Rob,

My packages work fine with parameters that have spaces.. it is only when the Core-Extensions is installed that the syntax changes and then breaks my packages.

The following syntax works ok with just Choco installed:
choco.exe install securities-full --params="'/SERVICENAME:SE /SEINSTALL:D:\ccviews\Program Files\securitease'" -y

But once the Core-Extensions are installed, the SEINSTALL parameter becomes D:\ccviews\Program

@ferventcoder
Copy link
Member

It does appear that choco tends to handle it correctly, but it is still not what is prescribed in our documentation, so it's technically a bug for core.extension.

@ferventcoder
Copy link
Member

Hi @deckjockey - we should have something in 0.10.9 that will override the core extension.

@ferventcoder
Copy link
Member

Moved the compatibility bits to #1490

@ferventcoder ferventcoder changed the title (chocolatey-core.extension) breaks Get-PackageParameters function if paramater contains spaces Get-PackageParameters - built-in should be preferred over chocolatey-core.extension Mar 4, 2018
@ferventcoder ferventcoder changed the title Get-PackageParameters - built-in should be preferred over chocolatey-core.extension Get-PackageParameters: built-in method should be preferred over chocolatey-core.extension Mar 4, 2018
@ferventcoder ferventcoder changed the title Get-PackageParameters: built-in method should be preferred over chocolatey-core.extension Get-PackageParameters: force built-in method to be preferred over chocolatey-core.extension Mar 4, 2018
@ferventcoder ferventcoder changed the title Get-PackageParameters: force built-in method to be preferred over chocolatey-core.extension Get-PackageParameters: force built-in method to be preferred over chocolatey-core.extension method Mar 4, 2018
ferventcoder referenced this issue Mar 4, 2018
Ensure that Chocolatey loads its version of Get-PackageParameters with
an alias.
@ferventcoder
Copy link
Member

ferventcoder commented Mar 4, 2018

This issue is now to ensure that the built-in Get-PackageParameters wins when there is both the built-in and the core extension.

ferventcoder added a commit that referenced this issue Mar 23, 2018
When renaming the function to force it's precedence over
Get-PackageParameters in the core extension, that causes the documents
to generate the name based on the renamed version. That needs to use
the original name. Change it back in generate docs just after importing
the module but prior to generating documentation.
ferventcoder added a commit that referenced this issue Mar 23, 2018
* stable:
  (doc) Get-PackageParameters - fix example
  (GH-1476) Ensure docs are for Get-PackageParameters
  (doc) update generated docs
  (doc) update release notes for 0.10.9
  (GH-1517) Fix: Given path's format is not supported
  (doc)(maint) CHANGELOG formatting
  (doc) update licensed CHANGELOG
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