Скрипт Powershell в WIX msi Installer - PullRequest
0 голосов
/ 06 января 2020

Не могли бы вы посоветовать, как мне вызвать скрипт Power-Shell для установки npm и некоторых других действий с помощью установщика WiX MSI.

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
 xmlns:powershell="http://schemas.gardiner.net.au/PowerShellWixExtensionSchema">
<?include Variables.wxi?>
<Product Id="$(var.ProductCode)" 
       Name="$(var.ProductName)" 
       Language="1033" Version="1.0.0.1" 
       Manufacturer="$(var.Manufacturer)"
       UpgradeCode="$(var.UpgradeCode)">

    <Package InstallerVersion="200" 
             Compressed="yes" 
             InstallScope="perMachine" />

    <Component Id="NpmInstallMain.ps1" Guid="e11556a2-e066-4393-af5c-9c9210187eba"  DiskId="1" Directory="INSTALLLOCATION">
      <File Id="NpmInstallMain.ps1" Name="NpmInstall.ps1" Source="$(var.SourceFolder)\NpmInstall.ps1"/>
    </Component>

    <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.">
      <![CDATA[Installed OR POWERSHELLEXE]]>
    </Condition>

    <SetProperty Id="RunStartScript"
             Before ="RunStartScript"
             Sequence="execute"
             Value="&quot;C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe&quot; -NonInteractive -ExecutionPolicy Bypass -InputFormat None -NoProfile -File &quot;[INSTALLDIR]/NpmInstall.ps1&quot;" />

    <CustomAction Id="RunStartScript" BinaryKey="WixCA" DllEntry="WixQuietExec" Execute="immediate" Return="check" Impersonate="no" />

    <InstallExecuteSequence>
      <Custom Action="RunStartScript" Before="InstallFinalize">NOT Installed OR UPGRADINGPRODUCTCODE</Custom>
    </InstallExecuteSequence>
    <UI>
        <ProgressText Action="NpmInstallMain">PowerShell Files (elevated)</ProgressText>
    </UI>
</Product>

Как определить причина проблемы? Я пытался регистрировать ошибки, используя консоль

msiexec /i CustomInstaller.msi /l*v MyLogFile.txt

Но это дает не так много полезной информации

Note: 1: 2228 2:  3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 1708 
Note: 1: 2228 2:  3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 1709 
...