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

Choco new silentargs can't pass in args in the param=value format #510

Closed
derek-robinson opened this issue Dec 17, 2015 · 17 comments
Closed
Assignees
Milestone

Comments

@derek-robinson
Copy link

Some applications like Operations Manager use a similar format to choco new to do pass in their arguments, e.g. USE_SETTINGS_FROM_AD={0|1} . (https://technet.microsoft.com/en-us/library/hh230736.aspx)

Creating a new package from template with silentarg="/qn /norestart USE_SETTINGS_FROM_AD=0" will create an emtpy string in the chocolateyInstall.ps1 file. I've tried quoting it several different ways (double quotes, single quotes, double quotes around single quotes, etc).

silentArgs    = ""

This is using Chocolatey v0.9.10-beta1

@ferventcoder
Copy link
Member

Interesting.

This is in the template? What exactly does it look like?

Like this?

silentarg="/qn /norestart USE_SETTINGS_FROM_AD=0"

@ferventcoder
Copy link
Member

and how are you calling choco new?

@ferventcoder
Copy link
Member

Ooooh, wait - choco new silentargs="/qn /norestart USE_SETTINGS_FROM_AD=0"?

@ferventcoder
Copy link
Member

To pass arguments with spaces - https://github.com/chocolatey/choco/wiki/CommandsReference#how-to-pass-options--switches

tl;dr:

Depending on whether you are running the command from powershell.exe or cmd.exe, this is how you should pass it:
choco new silentargs="'/qn /norestart USE_SETTINGS_FROM_AD=0'" - That is double quotes surrounding apostrophes. Shells make things harder than they need to be sometimes. :/

@ferventcoder
Copy link
Member

I think you also brought to light that in the default template this is broken - if you create a template and drop it into a template location as a replacement - add the SilentArgs back in as

[[SilentArgs]] - that's what choco uses for template replacement.

@ferventcoder ferventcoder added this to the 0.9.10 milestone Dec 17, 2015
@ferventcoder ferventcoder self-assigned this Dec 17, 2015
@derek-robinson
Copy link
Author

Running that command with the apostrophes in double quotes doesn't succeed in either cmd or powershell.

choco new scom --template embedded silentargs="'/qn /norestart USE_SETTINGS_FROM_AD=0'"

In my template, I had added the [[SilentArgs]]:

$packageArgs = @{
  packageName   = $packageName
  file          = $fileLocation
  fileType      = '[[InstallerType]]' #only one of these: exe, msi, msu

  silentArgs    = "[[SilentArgs]]"
  validExitCodes= @(0, 3010, 1641)
}

Result

$packageArgs = @{
  packageName   = $packageName
  file          = $fileLocation
  fileType      = 'EXE_MSI_OR_MSU' #only one of these: exe, msi, msu

  silentArgs    = ""
  validExitCodes= @(0, 3010, 1641)
}

This template succeeds if I don't pass the = operator.

choco new scom --template embedded silentargs="/qn /norestart USE_SETTINGS_FROM_AD 0"
$packageArgs = @{
  packageName   = $packageName
  file          = $fileLocation
  fileType      = 'EXE_MSI_OR_MSU' #only one of these: exe, msi, msu

  silentArgs    = "/qn /norestart USE_SETTINGS_FROM_AD 0"
  validExitCodes= @(0, 3010, 1641)
}

@ferventcoder
Copy link
Member

I'm going to try with -d --noop specified. That is a good way to see what it is actually assigning where.

@ferventcoder
Copy link
Member

It's a bug.

@ferventcoder
Copy link
Member

The code splits on =, so that will definitely need to get corrected. Thanks for filing an issue!

@ferventcoder
Copy link
Member

Do you have a workaround for now?

@derek-robinson
Copy link
Author

Yeah, we have a workaround. All I have to do is manually edit the file before packing it.
It breaks completely automating the package creation process , but I'm sure I can make something work in powershell to do the same thing until it gets resolved.

@derek-robinson
Copy link
Author

Thanks for looking into it! I was sure I was going crazy there for a while.

@ferventcoder
Copy link
Member

Almost fully automated package creation, you will have to tell me about that sometime 👍

sahebjade added a commit to sahebjade/choco that referenced this issue Dec 22, 2015
@sahebjade
Copy link
Contributor

I have created Pull Request #513 to fix the issue. if you like the fix, please can you merge. Thanks
https://travis-ci.org/chocolatey/choco/builds/98298512

@ferventcoder
Copy link
Member

The missing SilentArgs template value has been missing since 0.9.9.7 - 7b468c8 was the commit that introduced the regression.

ferventcoder added a commit that referenced this issue Dec 23, 2015
The SilentArgs argument can be specified with choco new, however the
template value was not in the install template. It was removed in
7b468c8. Add the template value back
in.
@ferventcoder
Copy link
Member

I've added the fix for allowing silentargs again in the default template. I see @sahebjade has created a PR to fix the = issue. I've added comments to the PR, if you wouldn't mind looking at those and making adjustments. Thanks!

ferventcoder added a commit that referenced this issue Dec 23, 2015
* stable:
  (maint) formatting
  (spec) Ensure MockLogger is setup first in test suite
  (specs) Allow for nupkgs to finish copying
  (specs) use deep copy for config
  (GH-516) Fix: Log.InitializeWith doesn't clear cached loggers
  (GH-445) Only fail scripts on non-zero exit code
  (GH-510) allow silentargs in template
ferventcoder pushed a commit that referenced this issue Jan 28, 2016
Some installers, MSIs in particular, specify silent arguments as
PROPERTY=value. Attempting to pass that in with
`choco new silentargs="/qn /norestart PROPERTY=value` will cause
choco to pass an empty string value in place of the passed arguments.

Fix the behavior to do the right thing when splitting the property
settings so that `=` can be passed as part of the arguments.
ferventcoder added a commit that referenced this issue Jan 28, 2016
* stable:
  (GH-510) Fix: args for new fail with param=value
@ferventcoder
Copy link
Member

Thanks! I just rebased this to stable and updated the commit message. This will go out in the next beta release in a couple of hours.

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

4 participants