-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
Issues with [\[] [\]] with using [XML] class #23
Comments
OK, I'll try attach as txt files... |
PS - I get the same script file error with the & one when I use the Test.ps1 from this codebase |
Not exactly sure, but I'd suggest starting with the examples in https://github.com/flcdrg/PowerShellWixExtension/tree/master/Tests (that do have escaped square brackets), and confirm that you can get those to work correctly. |
I too get a problem with the square brackets: <!-- Original script -->
</powershell:Script>
<powershell:Script Id="A" Elevated="yes"><![CDATA[
try{
$myProcess = Start-Process -NoNewWindow -PassThru -FilePath $Env:Programfiles'\A\A.exe'
Start-Sleep -Seconds 20
Stop-Process -Id $myProcess.Id[\[]0[\]] -ErrorAction SilentlyContinue
echo "Have fun"
}
catch{
Write-Host $_
}
]]>
</powershell:Script> Which becomes the following when launched from the MSI: <!-- Distorted script -->
</powershell:Script>
<powershell:Script Id="A" Elevated="yes"><![CDATA[
try{
$myProcess = Start-Process -NoNewWindow -PassThru -FilePath $Env:Programfiles'\A\A.exe'
Start-Sleep -Seconds 20
Stop-Process -Id $myProcess.Id[0] -ErrorAction SilentlyContinue
echo "Have fun"
}
catch{
Write-Host $_
}
-ErrorAction SilentlyContinue
echo "Have fun"
}
catch{
Write-Host $_
}
]]>
</powershell:Script> |
I'm really struggling to get this working properly with XML objects [[]xml[]]. So if I have as a simple example. I also tried an external powershell file and got an error also, but no less detail in the log.
if ($null -eq $null) {
[[]xml[]](Get-Content $CurrentConfig)
}
It is transformed to this in the msiexec log where it prints the script being run:
if ($null -eq $null)
(Get-Content $CurrentConfig)
}
So it is now missing "{ [[]xml[]]", so both the opening brace of the block, and the expected [xml] are gone.
Looking at the msiexec verbose log, the powershell script being executed is logged, and the script not only has the [[]xml[]] removed, the preceding { on the if statement has been removed also.
See the attached fragment 1.txt - It doesn't paste as code
The log section from msiexec is in the fragment 2.txt. It won't paste inline.
If I run the script from a file (using directly [xml]), I get this:
MSI (s) (DC:F4) [12:45:15:932]: Executing op: CustomActionSchedule(Action=PowerShellFilesDeferred,ActionType=1025,Source=BinaryData,Target=PowerShellFilesDeferred,CustomActionData=xml=<r> <d Id="UpdateBindings" file="" args="" IgnoreErrors="0" /> </r>) MSI (s) (DC:F8) [12:45:15:934]: Invoking remote custom action. DLL: C:\WINDOWS\Installer\MSI18D1.tmp, Entrypoint: PowerShellFilesDeferred SFXCA: Extracting custom action to temporary directory: C:\WINDOWS\Installer\MSI18D1.tmp-\ SFXCA: Binding to CLR version v4.0.30319 Calling custom action PowerShellActions!PowerShellActions.CustomActions.PowerShellFilesDeferred PowerShellFilesDeferred start PowerShell terminating error, returning Failure System.Management.Automation.RuntimeException: The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command name, a script block, or a CommandInfo object. at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input) at PowerShellActions.PowerShellTask.Execute() at PowerShellActions.CustomActions.FilesDeferred(Session session, String deferredProperty) CustomAction PowerShellFilesDeferred returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox) Action ended 12:45:16: InstallFinalize. Return value 3. MSI (s) (DC:F4) [12:45:16:724]: Note: 1: 2265 2: 3: -2147287035
The text was updated successfully, but these errors were encountered: