In this case it is a 64 bit MSI (our services installer has a 32 bit and a 64
bit MSI based on the bitness of the OS, in this case testing with 64 bit MSI)
since the path is:
MSI (s) (30:B0) [12:56:34:248]: Executing op:
CustomActionSchedule(Action=CA_NSERVICEBUSLICENSE.CA23A0DC_B2DE_4F2C_9E74_FD373F99E9D7,ActionType=3073,Source=BinaryData,Target=InstallNServiceBusLicense,CustomActionData="C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"|-NoProfile
-NonInteractive -InputFormat None -ExecutionPolicy Bypass -Command "&
'C:\Program Files\MYCORP\MYCORP Services\Common\RegisterLicense.ps1' ; exit
$($Error.Count)"|C:\Program Files\TITUS\TITUS Services\Common)
I even tried using a custom action in my CA DLL:
[CustomAction]
public static ActionResult InstallNServiceBusLicense(Session session)
{
try
{
if (session == null)
{
throw new ArgumentNullException("session");
}
var tempString = GetSessionProperty(session,
"CustomActionData", false);
var parts = tempString.Split(new[] { '|' });
var cmdLineExe = parts[0];
var cmdLineParameters = parts[1];
var commonFolder = parts[2];
var path = @commonFolder + "\\RegisterLicense.ps1";
var currentFolder = Directory.GetCurrentDirectory();
Directory.SetCurrentDirectory(commonFolder);
if (Directory.Exists(commonFolder))
{
// Create a file to write to.
using (StreamWriter sw = File.CreateText(path))
{
sw.WriteLine("CD " + commonFolder);
sw.WriteLine("Import-Module .\\NServiceBus.Core.dll");
sw.WriteLine("Install-License -Path .\\License.xml");
}
}
// run PowerShell on the script
if (File.Exists(path))
{
var runPowerShellInfo = new ProcessStartInfo
{
UseShellExecute = true,
Arguments = cmdLineParameters,
FileName = cmdLineExe,
WindowStyle = ProcessWindowStyle.Hidden,
CreateNoWindow = true
};
// Run the external process & wait for it to finish
using (Process runPowerShellProc =
Process.Start(runPowerShellInfo))
{
runPowerShellProc.WaitForExit();
}
}
Directory.SetCurrentDirectory(currentFolder);
}
catch (Exception ex)
{
WriteErrorLogInstall(session, "InstallNServiceBusLicense
failed: ", ex, true);
}
return ActionResult.Success;
}
-----Original Message-----
From: Castro, Edwin G. (Hillsboro) [mailto:[email protected]]
Sent: March-06-13 1:22 PM
To: General discussion for Windows Installer XML toolset.
Subject: Re: [WiX-users] Running PowerShell script...
The useLegacyV2RuntimeActivationPolicy="true" is what allows .NET 4 to load
.NET 2 assemblies so you need that. You don't want to remove it.
I assume you checked the system where the MSI is installing so my next guess is
that 64-bit powershell has the configuration file while 32-bit powershell does
not and the MSI is executing 32-bit powershell.
Edwin G. Castro
Software Developer - Staff
Digital Channels
Fiserv
Office: 503-746-0643
Fax: 503-617-0291
www.fiserv.com
> -----Original Message-----
> From: Steven Ogilvie [mailto:[email protected]]
> Sent: Wednesday, March 06, 2013 9:53 AM
> To: General discussion for Windows Installer XML toolset.
> Subject: Re: [WiX-users] Running PowerShell script...
>
> Hmm
>
> Your right I have PS version 3 but the powershell config is loading
> .NET 4
>
> <?xml version="1.0" encoding="utf-8" ?> <configuration>
> <startup useLegacyV2RuntimeActivationPolicy="true">
> <supportedRuntime version="v4.0" />
> </startup>
> </configuration>
>
> So why is it still failing? Is it because of the legacyV2 is set to true?
>
> -----Original Message-----
> From: Castro, Edwin G. (Hillsboro) [mailto:[email protected]]
> Sent: March-06-13 12:25 PM
> To: General discussion for Windows Installer XML toolset.
> Subject: Re: [WiX-users] Running PowerShell script...
>
> My guess would be that you have PowerShell v3 installed on your system.
> Check the value of the $PSVersionTable variable in PowerShell as that
> will give you detailed version information for PowerShell.
>
> Edwin G. Castro
> Software Developer - Staff
> Digital Channels
> Fiserv
> Office: 503-746-0643
> Fax: 503-617-0291
> www.fiserv.com
>
> > -----Original Message-----
> > From: StevenOgilvie [mailto:[email protected]]
> > Sent: Tuesday, March 05, 2013 9:43 PM
> > To: [email protected]
> > Subject: Re: [WiX-users] Running PowerShell script...
> >
> > Why is it that I can run the script in a dos box I.e.
> > powershell.exe
> > .\registerlicense.ps1 and it works ______________________ Steven
> > Ogilvie
> >
> > Sent from my BlackBerry...
> >
> > 3 - 45 Bertrand Street
> > Ottawa, ON
> > Canada
> > K1M 1Y5
> >
> > Mobile: +1 613 299-2121
> > E-mail: [email protected]
> >
> > -----Original Message-----
> > From: "Edwin G. Castro [via Windows Installer XML (WiX) toolset]"
> > <ml-
> > [email protected]>
> > Date: Tue, 5 Mar 2013 23:00:13
> > To: <[email protected]>
> > Subject: Re: Running PowerShell script...
> >
> > Here's the bit that's important:
> >
> > CAQuietExec: Import-Module : Could not load file or assembly
> > 'file:///C:\Program Files\MYCORP
> > CAQuietExec: \MYCORP Services\Common\NServiceBus.Core.dll' or one
> > of its dependencies. This a
> > CAQuietExec: ssembly is built by a runtime newer than the currently
> > loaded runtime and cannot be loaded.
> >
> > This is telling you that the assembly you are trying to load is
> > probably compiled against .NET 4 while PowerShell is loading the
> > .NET 2
> runtime.
> > PowerShell v3 loads the .NET 4 runtime but PowerShell v2 still only
> > loads the .NET 2 runtime. The easiest solution if you can manage it
> > is to get NServiceBus.Core.dll compiled against the .NET 2 runtime
> > (.NET
> > 3.5 would work too). Otherwise you'll need to decide whether you'll
> > only support PowerShell v3 OR create/customize a
> > PowerShell.exe.config that allows PowerShell to load the .NET 4 runtime.
> >
> > Edwin G. Castro
> > Software Developer - Staff
> > Digital Channels
> > Fiserv
> > Office: 503-746-0643
> > Fax: 503-617-0291
> > www.fiserv.com
> >
> >
> > > -----Original Message-----
> > > From: StevenOgilvie [mailto:[hidden email]
> > > </user/SendEmail.jtp?type=node&node=7584125&i=0> ]
> > > Sent: Tuesday, March 05, 2013 2:14 PM
> > > To: [hidden email]
> </user/SendEmail.jtp?type=node&node=7584125&i=1>
> > > Subject: [WiX-users] Running PowerShell script...
> > >
> > > Hi guys
> > >
> > > I have googled and done everything I think I should have done but
> > > I am getting a funky error in the MSI log file, has anyone else
> > > had this issue, if so how did you fix it?
> > >
> > > Install the Powershell file
> > > <Component Id="cmp_RegisterNServiceBusLicense"
> > > Guid="{276C369D-BF32-472F-A7FC-24155DEB18DE}">
> > > <File Id="file_RegisterNServiceBusLicense" KeyPath="yes"
> > > Source="..\$(var.resourcePath)\RegisterLicense.ps1" />
> > > </Component>
> > >
> > >
> > > Set the custom action
> > > <CustomAction Id="CA_SetNServiceBusLicense"
> > > Property="CA_NSERVICEBUSLICENSE"
> > > Value =""[POWERSHELLEXE]" -Version 2.0 -NoProfile -
> > > NonInteractive -InputFormat None -ExecutionPolicy Bypass -Command
> > > "& '[#file_RegisterNServiceBusLicense]' ; exit
> > > $$($Error.Count)"" />
> > > <CustomAction Id="CA_NSERVICEBUSLICENSE" BinaryKey="WixCA"
> > > DllEntry="CAQuietExec" Execute="deferred" Return="check"
> > > Impersonate="no" />
> > > <UI>
> > > <ProgressText Action="CA_NSERVICEBUSLICENSE">CA: Installing
> > > NServiceBus license...</ProgressText>
> > > </UI>
> > >
> > > Sequence the custom action
> > > <InstallExecuteSequence>
> > > <Custom Action="CA_SetNServiceBusLicense"
> > > After="InstallValidate"></Custom> <Custom
> > > Action="CA_NSERVICEBUSLICENSE" Before="InstallServices">NOT
> > > Installed</Custom>
> > >
> > > Get the powershell path:
> > >
> > > <Property Id="POWERSHELLEXE">
> > > <RegistrySearch Id="POWERSHELLEXE"
> > > Type="raw"
> > > Root="HKLM"
> > >
> > >
> Key="SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell"
> > > Name="Path" />
> > > </Property>
> > > <Condition Message="This application requires Windows
> > > PowerShell.">
> > >
> > > </Condition>
> > >
> > > The powershell script itself is pretty basic:
> > > C:
> > > CD "C:\Program Files\MYCORP\MYCORP Services\Common"
> > > Import-Module .\NServiceBus.Core.dll Install-License -Path
> > > .\License.xml
> > >
> > >
> > > The error in the msi logfile:
> > >
> > > Action 17:00:34:
> > > CA_NSERVICEBUSLICENSE.CA23A0DC_B2DE_4F2C_9E74_FD373F99E9D7.
> > > CA: Installing NServiceBus license...
> > > MSI (s) (5C:48) [17:00:34:296]: Executing op:
> > >
> >
> CustomActionSchedule(Action=CA_NSERVICEBUSLICENSE.CA23A0DC_B2DE_
> > >
> >
> 4F2C_9E74_FD373F99E9D7,ActionType=3073,Source=BinaryData,Target=CAQ
> > >
> >
> uietExec,CustomActionData="C:\Windows\System32\WindowsPowerShell\v
> > > 1.0\powershell.exe"
> > > -Version 2.0 -NoProfile -NonInteractive -InputFormat None
> > > -ExecutionPolicy Bypass -Command "& 'C:\Program
> > > Files\MYCORP\MYCORPServices\Common\RegisterLicense.ps1' ; exit
> > > $($Error.Count)")
> > > MSI (s) (5C:64) [17:00:34:317]: Invoking remote custom action. DLL:
> > > C:\Windows\Installer\MSI8EA2.tmp, Entrypoint: CAQuietExec
> > > CAQuietExec: Entering CAQuietExec in
> > > C:\Windows\Installer\MSI8EA2.tmp, version 3.7.1224.0
> > > CAQuietExec:
> > > "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
> > > -Version 2.0 -NoProfile -NonInteractive -InputFormat None
> > > -ExecutionPolicy Bypass -Command "& 'C:\Program
> > Files\MYCORP\MYCORP
> > > Services\Common\RegisterLicense.ps1' ; exit $($Error.Count)"
> > > CAQuietExec: Import-Module : Could not load file or assembly
> > > 'file:///C:\Program Files\MYCORP
> > > CAQuietExec: \MYCORP Services\Common\NServiceBus.Core.dll' or one
> > > of its dependencies. This a
> > > CAQuietExec: ssembly is built by a runtime newer than the
> > > currently loaded runtime and cannot be loaded.
> > > CAQuietExec: At C:\Program Files\MYCORP\MYCORP
> > > Services\Common\RegisterLicense.ps1:5 char:14
> > > CAQuietExec: + Import-Module <<<< .\NServiceBus.Core.dll +
> > > CategoryInfo
> > > : NotSpecified: (:) , BadImageFormatException
> > > CAQuietExec: + FullyQualifiedErrorId :
> > >
> >
> System.BadImageFormatException,Microsoft.PowerShell.Commands.Import
> > > ModuleCommand
> > > CAQuietExec:
> > > CAQuietExec: Install-License : The term 'Install-License' is not
> > > recognized as the name of a
> > > CAQuietExec: cmdlet, function, script file, or operable program.
> > > Check the spelling of the
> > > CAQuietExec: name, or if a path was included, verify that the
> > > path is correct and try again.
> > > CAQuietExec: At C:\Program Files\MYCORP\MYCORP
> > > Services\Common\RegisterLicense.ps1:6 char:16
> > > CAQuietExec: + Install-License <<<< -Path .\License.xml
> > > CAQuietExec: + CategoryInfo : ObjectNotFound:
> > > (Install-License:String) , Com
> > > CAQuietExec: mandNotFoundException
> > > CAQuietExec: + FullyQualifiedErrorId :
> > > CommandNotFoundException
> > > CAQuietExec:
> > > CAQuietExec: Error 0x80070002: Command line returned an error.
> > > CAQuietExec: Error 0x80070002: CAQuietExec Failed CustomAction
> > > CA_NSERVICEBUSLICENSE.CA23A0DC_B2DE_4F2C_9E74_FD373F99E9D7
> > > returned actual error code 1603 (note this may not be 100%
> > > accurate if translation happened inside sandbox)
> > >
> > > thanks,
> > >
> > > Steve
> > >
> > >
> > >
> > >
> > > --
> > > View this message in context: http://windows-installer-xml-wix-
> > > toolset.687559.n2.nabble.com/Running-PowerShell-script-tp7584122.h
> > > tm l Sent from the wix-users mailing list archive at Nabble.com.
> > >
> > > ------------------------------------------------------------------
> > > --
> > > --
> > > -------- Symantec Endpoint Protection 12 positioned as A LEADER in
> > > The Forrester
> > > Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice"
> > > in the endpoint security space. For insight on selecting the right
> > > partner to tackle endpoint security challenges, access the full report.
> > > http://p.sf.net/sfu/symantec-dev2dev
> > > _______________________________________________
> > > WiX-users mailing list
> > > [hidden email] </user/SendEmail.jtp?type=node&node=7584125&i=2>
> > > https://lists.sourceforge.net/lists/listinfo/wix-users
> > --------------------------------------------------------------------
> > --
> > -------- Symantec Endpoint Protection 12 positioned as A LEADER in
> > The Forrester
> > Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in
> > the endpoint security space. For insight on selecting the right
> > partner to tackle endpoint security challenges, access the full report.
> > http://p.sf.net/sfu/symantec-dev2dev
> > _______________________________________________
> > WiX-users mailing list
> > [hidden email] </user/SendEmail.jtp?type=node&node=7584125&i=3>
> > https://lists.sourceforge.net/lists/listinfo/wix-users
> >
> >
> >
> > ----------------
> >
> >
> > If you reply to this email, your message will be added to the discussion
> > below: http://windows-installer-xml-wix-
> > toolset.687559.n2.nabble.com/Running-PowerShell-script-
> > tp7584122p7584125.html
> > To unsubscribe from Running PowerShell
> script..., click here
> > <http://windows-installer-xml-wix-
> >
> toolset.687559.n2.nabble.com/template/NamlServlet.jtp?macro=unsubscrib
> >
> e_by_code&node=7584122&code=c29naWx2aWVAbXNuLmNvbX
> > w3NTg0MTIyfC0xMzAxOTI3MzMx> .
> > NAML <http://windows-installer-xml-wix-
> >
> toolset.687559.n2.nabble.com/template/NamlServlet.jtp?macro=macro_vie
> >
> wer&id=instant_html%21nabble%3Aemail.naml&base=nabble.na
> > ml.namespaces.BasicNamespace-
> > nabble.view.web.template.NabbleNamespace-
> >
> nabble.view.web.template.NodeNamespace&breadcrumbs=notify_su
> > bscribers%21nabble%3Aemail.naml-
> > instant_emails%21nabble%3Aemail.naml-
> > send_instant_email%21nabble%3Aemail.naml>
> >
> >
> >
> >
> > --
> > View this message in context: http://windows-installer-xml-wix-
> > toolset.687559.n2.nabble.com/Running-PowerShell-script-
> > tp7584122p7584127.html
> > Sent from the wix-users mailing list archive at Nabble.com.
> > --------------------------------------------------------------------
> > --
> > -------- Symantec Endpoint Protection 12 positioned as A LEADER in
> > The Forrester
> > Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in
> > the endpoint security space. For insight on selecting the right
> > partner to tackle endpoint security challenges, access the full report.
> > http://p.sf.net/sfu/symantec-dev2dev
> > _______________________________________________
> > WiX-users mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/wix-users
> ----------------------------------------------------------------------
> -------- Symantec Endpoint Protection 12 positioned as A LEADER in The
> Forrester
> Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in
> the endpoint security space. For insight on selecting the right
> partner to tackle endpoint security challenges, access the full report.
> http://p.sf.net/sfu/symantec-dev2dev
> _______________________________________________
> WiX-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wix-users
> ----------------------------------------------------------------------
> -------- Symantec Endpoint Protection 12 positioned as A LEADER in The
> Forrester
> Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in
> the endpoint security space. For insight on selecting the right
> partner to tackle endpoint security challenges, access the full report.
> http://p.sf.net/sfu/symantec-dev2dev
> _______________________________________________
> WiX-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wix-users
------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
endpoint security space. For insight on selecting the right partner to tackle
endpoint security challenges, access the full report.
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
WiX-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wix-users
------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
endpoint security space. For insight on selecting the right partner to
tackle endpoint security challenges, access the full report.
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
WiX-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wix-users