Closed derek-robinson closed 8 years ago
Interesting.
This is in the template? What exactly does it look like?
Like this?
silentarg="/qn /norestart USE_SETTINGS_FROM_AD=0"
and how are you calling choco new?
Ooooh, wait - choco new silentargs="/qn /norestart USE_SETTINGS_FROM_AD=0"
?
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. :/
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.
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)
}
I'm going to try with -d --noop
specified. That is a good way to see what it is actually assigning where.
It's a bug.
The code splits on =
, so that will definitely need to get corrected. Thanks for filing an issue!
Do you have a workaround for now?
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.
Thanks for looking into it! I was sure I was going crazy there for a while.
Almost fully automated package creation, you will have to tell me about that sometime :+1:
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
The missing SilentArgs template value has been missing since 0.9.9.7 - 7b468c8e6ff41913c5fa29499d2ad8cb681a96cb was the commit that introduced the regression.
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!
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.
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).
This is using Chocolatey v0.9.10-beta1