简体   繁体   中英

Wix Burn: How to reboot after installing a MsuPackage

I currently have a scenario whereby I need to do the following using burn

  1. Install Windows Imaging Component
  2. Install Windows Installer 4.5
  3. Install .Net 4 Web
  4. Run my installer (created using Wix 3.6)

I would like to know if there is a way to force a restart after installing a MsuPackage...

In my scenario, when the bootstrapper installs Windows6.0-KB942288-v2-x86.msu on windows vista and subsequently tries to install the .Net Framework without restarting it throws an error: 0x8007064d - This installation package cannot be installed by the windows installer service...

If I restart after the error and run the setup again it works correctly. Note that with a ExePackage a InstallCommand can be specified as well as a ExitCode, How can I achieve the same behavior in a MsuPackage?

Please see the contents of my wxs file below:

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" 
     xmlns:bal="http://schemas.microsoft.com/wix/BalExtension" 
     xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
  <Bundle Name="$(var.MyProject.ProjectName)" Version="2.6.0.0" Manufacturer="Awesome Software (Pty) Ltd" UpgradeCode="6a77118d-c132-4454-850b-935edc287945">
    <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense">
      <bal:WixStandardBootstrapperApplication
        LicenseFile="$(var.SolutionDir)Awesome.EULA\Awesome CE Eula.rtf"
        SuppressOptionsUI="yes"/>
    </BootstrapperApplicationRef>

    <util:FileSearch Path="[SystemFolder]\windowscodecs.dll" Variable="windowscodecs" Result="exists" />

    <Chain>
      <!-- Windows Imaging Component-->
      <ExePackage Cache="no" Compressed="no" PerMachine="yes" Permanent="yes" Vital="yes"
        SourceFile="redist\wic_x86_enu.exe"
        DownloadUrl="http://download.microsoft.com/download/f/f/1/ff178bb1-da91-48ed-89e5-478a99387d4f/wic_x86_enu.exe"
        InstallCondition="VersionNT &lt; v5.2 AND NOT VersionNT64"
        DetectCondition="windowscodecs"
        InstallCommand="/quiet /norestart">
      </ExePackage>
      <ExePackage Cache="no" Compressed="no" PerMachine="yes" Permanent="yes" Vital="yes"
        SourceFile="redist\wic_x64_enu.exe"
        DownloadUrl="http://download.microsoft.com/download/6/4/5/645FED5F-A6E7-44D9-9D10-FE83348796B0/wic_x64_enu.exe"
        InstallCondition="VersionNT &lt; v5.2 AND VersionNT64"
        DetectCondition="windowscodecs"
        InstallCommand="/quiet /norestart">
      </ExePackage>
      <!-- Windows Installer 4.5 -->
      <ExePackage Cache="no" Compressed="no" PerMachine="yes" Permanent="yes" Vital="yes"
          SourceFile="redist\WindowsXP-KB942288-v3-x86.exe"
          DownloadUrl="http://download.microsoft.com/download/2/6/1/261fca42-22c0-4f91-9451-0e0f2e08356d/WindowsXP-KB942288-v3-x86.exe"
          InstallCondition="VersionNT=v5.1 AND NOT VersionNT64 AND VersionMsi &lt; v4.5"
          InstallCommand="/quiet /norestart">
        <ExitCode Behavior="forceReboot"/>
      </ExePackage>
      <ExePackage Cache="no" Compressed="no" PerMachine="yes" Permanent="yes" Vital="yes"
          SourceFile="redist\WindowsServer2003-KB942288-v4-x86.exe"
          DownloadUrl="http://download.microsoft.com/download/2/6/1/261fca42-22c0-4f91-9451-0e0f2e08356d/WindowsServer2003-KB942288-v4-x86.exe"
          InstallCondition="VersionNT=v5.2 AND NOT VersionNT64 AND VersionMsi &lt; v4.5"
          InstallCommand="/quiet /norestart">
        <ExitCode Behavior="forceReboot"/>
      </ExePackage>
      <ExePackage Cache="no" Compressed="no" PerMachine="yes" Permanent="yes" Vital="yes"
          SourceFile="redist\WindowsServer2003-KB942288-v4-x64.exe"
          DownloadUrl="http://download.microsoft.com/download/2/6/1/261fca42-22c0-4f91-9451-0e0f2e08356d/WindowsServer2003-KB942288-v4-x64.exe"
          InstallCondition="VersionNT=v5.2 AND VersionNT64 AND VersionMsi &lt; v4.5"
          InstallCommand="/quiet /norestart">
        <ExitCode Behavior="forceReboot"/>
      </ExePackage>
      <MsuPackage Cache="no" Compressed="no" Permanent="yes" Vital="yes" KB="KB942288" 
          SourceFile="redist\Windows6.0-KB942288-v2-x86.msu"
          DownloadUrl="http://download.microsoft.com/download/2/6/1/261fca42-22c0-4f91-9451-0e0f2e08356d/Windows6.0-KB942288-v2-x86.msu"
          InstallCondition="VersionNT=v6.0 AND NOT VersionNT64 AND VersionMsi &lt; v4.5">
      </MsuPackage>
      <MsuPackage Cache="no" Compressed="no" Permanent="yes" Vital="yes" KB="KB942288"
          SourceFile="redist\Windows6.0-KB942288-v2-x64.msu"
          DownloadUrl="http://download.microsoft.com/download/2/6/1/261fca42-22c0-4f91-9451-0e0f2e08356d/Windows6.0-KB942288-v2-x64.msu"
          InstallCondition="VersionNT=v6.0 AND VersionNT64 AND VersionMsi &lt; v4.5">
      </MsuPackage>
      <PackageGroupRef Id="NetFx40Web"/>
      <RollbackBoundary />
      <MsiPackage Id="MaxCut" SourceFile=".\StagingBundle\Awesome.msi" DisplayInternalUI="no"/>
    </Chain>
  </Bundle>
</Wix>

MsuPackage restarts are automatically detected. The MSU you installed might have said it required a restart (the log file should say something, IIRC) but did not need to force a restart. It has been request to have Burn have a way to promote a "restart required" to a "restart now if any restarts are required at this point" in the chain. Unfortunately, at this point that feature does not exist yet.

However, you can implement the "force restart now" behavior in a custom BootstrapperApplication by return IDRESTART from OnExecutePackageComplete() callback. That's the only option until someone implements the feature.

I needed to do this recently, and didn't want to have to write a bootstrapper app or create additional bootstrapper EXEs for each MSU

As a workaround I added an executable that does nothing (NOP.EXE) to run after the MsuPackage and used ExitCode to force a reboot.

You need to use the same DetectCondition for both the MsuPackage and the ExePackage .

You can use the same executable after multiple MsuPackages

So something like...

  <Fragment>
    <util:FileSearch Path="PathToSomeDotNetDll" Result="version" Variable="DotNetVersionCheck" />
    <PackageGroup Id="net45_x86">
      <MsuPackage Cache="no"
                  Compressed="no"
                  DetectCondition="DotNetVersionCheck &gt;= v4.5"
                  Permanent="yes"
                  Vital="yes"
                  KB="KB942288"
                  SourceFile="redist\Windows6.0-KB942288-v2-x86.msu"
                  DownloadUrl="http://download.microsoft.com/download/2/6/1/261fca42-22c0-4f91-9451-0e0f2e08356d/Windows6.0-KB942288-v2-x86.msu"
                  InstallCondition="VersionNT=v6.0 AND NOT VersionNT64 AND VersionMsi &lt; v4.5">
      </MsuPackage>
      <!-- Trick the bootstrapper into rebooting now by running an executable that does nothing and set ExitCode to force a reboot -->
      <ExePackage SourceFile="bin\nop.exe"
                  DisplayName="Reboot required after KB942288"
                  DetectCondition="DotNetVersionCheck &gt;= v4.5"
                  InstallCommand="nop.exe"
                  InstallCondition="VersionNT=v6.0 AND NOT VersionNT64 AND VersionMsi &lt; v4.5"
                  Permanent="yes">
        <ExitCode Behavior="forceReboot"/>
      </ExePackage>
    </PackageGroup>
  </Fragment>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM