【问题标题】:Installation should be executed twice to install the major upgrade for the application应执行两次安装以安装应用程序的主要升级
【发布时间】:2015-10-09 14:28:34
【问题描述】:

以下安装无法正常进行重大升级。
如果当前PC上安装了以前版本的应用程序,那么在重大升级期间,旧版本将自动卸载,但由于某种原因没有安装新版本。
我需要运行此新安装两次才能卸载旧版本,然后安装新版本。
但是如果我在旧版本安装中注释掉自定义动作LaunchApplication,那么不会有任何问题,并且在新安装的一次运行期间将卸载旧版本并安装新版本。

<?xml version='1.0' encoding='windows-1252'?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

  <Product Name='Foobar 2.0.0' Id='GUID' UpgradeCode='GUID'
    Language='1033' Codepage='1252' Version='2.0.0' Manufacturer='Acme Ltd.'>

    <Package Id='*' Keywords='Installer' Description="Acme's Foobar 2.0.0 Installer"
      Comments='Foobar is a registered trademark of Acme Ltd.' Manufacturer='Acme Ltd.'
      InstallerVersion='100' Languages='1033' Compressed='yes' SummaryCodepage='1252' />

    <Property Id="ALLUSERS" Secure="yes" Value="2" />
    <Property Id="MSIINSTALLPERUSER" Secure="yes" Value="1" />
    <Property Id='ApplicationFolderName' Value="Acme" />
    <Property Id='WixAppFolder' Value="WixPerUserFolder" />

    <Upgrade Id='GUID'>
       <UpgradeVersion OnlyDetect='no' Property='PREVIOUSFOUND'
           Minimum='0.0.1' IncludeMinimum='yes'
           Maximum='2.0.0' IncludeMaximum='no' />
          <UpgradeVersion OnlyDetect='yes' Property='NEWERFOUND'
             Minimum='2.0.0' IncludeMinimum='no' />
    </Upgrade>

    <Media Id='1' Cabinet='Sample.cab' EmbedCab='yes' DiskPrompt="CD-ROM #1" />
    <Property Id='DiskPrompt' Value="Acme's Foobar 2.0.0 Installation [1]" />

    <Directory Id='TARGETDIR' Name='SourceDir'>
      <Directory Id='ProgramFilesFolder' Name='PFiles'>
        <Directory Id='Acme' Name='Acme'>
          <Directory Id='INSTALLDIR' Name='Foobar 2.0.0'>
          </Directory>
        </Directory>
      </Directory>
    </Directory>

    <DirectoryRef Id="INSTALLDIR">
       <Component Id='start.vbs' Guid='GUID'>
          <File Id='start.vbs' Name='start.vbs' DiskId='1' Source='start.vbs' KeyPath='yes' >
          </File>
       </Component>
    </DirectoryRef>

    <Feature Id='Complete' Title='Foobar 2.0.0' Description='The complete package.'
      Display='expand' Level='1' ConfigurableDirectory='INSTALLDIR'>
      <Feature Id='MainProgram' Title='Program' Description='The main executable.' Level='1'>
        <ComponentRef Id='start.vbs' />
      </Feature>
    </Feature>

    <CustomAction Id='AlreadyUpdated' Error='[ProductName] has already been updated to 2.0.0 or newer.' />
    <CustomAction Id='NoDowngrade' Error='A later version of [ProductName] is already installed.' />

    <Property Id="WixShellExecTarget" Value="[#start.vbs]" />
    <CustomAction Id="LaunchApplication" 
        BinaryKey="WixCA" 
        DllEntry="WixShellExec"
        Execute="immediate"
        Impersonate="yes" />

    <InstallExecuteSequence>
         <Custom Action='AlreadyUpdated' After='FindRelatedProducts'>SELFFOUND</Custom>
         <Custom Action="NoDowngrade" After="FindRelatedProducts">NEWERFOUND</Custom>

         <RemoveExistingProducts Before="InstallInitialize" />

         <Custom Action="LaunchApplication" After="InstallFinalize"/>

    </InstallExecuteSequence>
  </Product>
</Wix>

此安装或自定义操作可能有什么问题?
VBS 程序为空。
开始.vbs:

Private Function startServerSub()
End Function
startServerSub

应该进行哪些更改才能在运行新应用程序时卸载旧版本并安装新版本?

更新:
我稍微改变了我的安装。
1. RemoveExistingProducts 会在 InstallInitialize 之后执行。
2. 升级元素新增SELFFOUND。

<?xml version='1.0' encoding='windows-1252'?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

  <Product Name='TestApp 2.0.0' Id='GUID' UpgradeCode='GUID'
    Language='1033' Codepage='1252' Version='2.0.0' Manufacturer='TestManufacturer Ltd.'>

    <Package Id='*' Keywords='Installer' Description="TestManufacturer's TestApp 2.0.0 Installer"
      Comments='TestAppis a registered trademark of TestManufacturer Ltd.' Manufacturer='TestManufacturer Ltd.'
      InstallerVersion='100' Languages='1033' Compressed='yes' SummaryCodepage='1252' />

    <Property Id="ALLUSERS" Secure="yes" Value="2" />
    <Property Id="MSIINSTALLPERUSER" Secure="yes" Value="1" />
    <Property Id='ApplicationFolderName' Value="TestManufacturer" />
    <Property Id='WixAppFolder' Value="WixPerUserFolder" />

    <Upgrade Id='GUID'>
       <UpgradeVersion OnlyDetect='yes' Property='SELFFOUND'
           Minimum='2.0.0' IncludeMinimum='yes'
           Maximum='2.0.0' IncludeMaximum='yes' />
       <UpgradeVersion OnlyDetect='no' Property='PREVIOUSFOUND'
           Minimum='0.0.1' IncludeMinimum='yes'
           Maximum='2.0.0' IncludeMaximum='no' />
          <UpgradeVersion OnlyDetect='yes' Property='NEWERFOUND'
             Minimum='2.0.0' IncludeMinimum='no' />
    </Upgrade>

    <Media Id='1' Cabinet='Sample.cab' EmbedCab='yes' DiskPrompt="CD-ROM #1" />
    <Property Id='DiskPrompt' Value="TestManufacturer's TestApp 2.0.0 Installation [1]" />

    <Directory Id='TARGETDIR' Name='SourceDir'>
      <Directory Id='ProgramFilesFolder' Name='PFiles'>
        <Directory Id='TestManufacturer' Name='TestManufacturer'>
          <Directory Id='INSTALLDIR' Name='TestApp 2.0.0'>
          </Directory>
        </Directory>
      </Directory>
    </Directory>

    <DirectoryRef Id="INSTALLDIR">
       <Component Id='start.vbs' Guid='GUID'>
          <File Id='start.vbs' Name='start.vbs' DiskId='1' Source='start.vbs' KeyPath='yes' >
          </File>
       </Component>
    </DirectoryRef>

    <Feature Id='Complete' Title='TestApp 2.0.0' Description='The complete package.'
      Display='expand' Level='1' ConfigurableDirectory='INSTALLDIR'>
      <Feature Id='MainProgram' Title='Program' Description='The main executable.' Level='1'>
        <ComponentRef Id='start.vbs' />
      </Feature>
    </Feature>

    <CustomAction Id='AlreadyUpdated' Error='[ProductName] has already been updated to 2.0.0 or newer.' />
    <CustomAction Id='NoDowngrade' Error='A later version of [ProductName] is already installed.' />

    <Property Id="WixShellExecTarget" Value="[#start.vbs]" />
    <CustomAction Id="LaunchApplication" 
        BinaryKey="WixCA" 
        DllEntry="WixShellExec"
        Execute="immediate"
        Impersonate="yes" />

    <InstallExecuteSequence>
         <Custom Action='AlreadyUpdated' After='FindRelatedProducts'>SELFFOUND</Custom>
         <Custom Action="NoDowngrade" After="FindRelatedProducts">NEWERFOUND</Custom>

         <RemoveExistingProducts After="InstallInitialize" />

         <Custom Action="LaunchApplication" After="InstallFinalize"/>

    </InstallExecuteSequence>

  </Product>
</Wix>

然后我创建了4个安装包:
1. 1.0.0 版,在 InstallFinalize 之后具有自定义操作 LaunchApplication。
2. 版本 1.0.0 没有自定义操作 LaunchApplication。
3. 2.0.0 版,在 InstallFinalize 之后具有自定义操作 LaunchApplication。
4. 没有自定义操作 LaunchApplication 的 2.0.0 版。

如果安装了带有自定义操作的 1.0.0 版,则无法安装任何类型的 2.0.0 版。

我尝试在 1.0.0 版(有自定义动作)之后安装 2.0.0 版(无自定义动作):

=== Verbose logging started: 7/22/2015  18:37:48  Build type: SHIP UNICODE 5.00.7601.00  Calling process: C:\Windows\system32\msiexec.EXE ===  
...  
Action 18:37:48: FindRelatedProducts. Searching for related applications  
Action start 18:37:48: FindRelatedProducts.  
FindRelatedProducts: Found application: {GUID of 1.0.0}  
MSI (c) (A8:A4) [18:37:48:221]: PROPERTY CHANGE: Adding PREVIOUSFOUND property. Its value is '{GUID of 1.0.0}'.  
...  
Action start 18:37:48: InstallInitialize.  
MSI (s) (F4:0C) [18:37:48:299]: Machine policy value 'AlwaysInstallElevated' is 0  
MSI (s) (F4:0C) [18:37:48:299]: User policy value 'AlwaysInstallElevated' is 0  
MSI (s) (F4:0C) [18:37:48:299]: BeginTransaction: Locking Server  
MSI (s) (F4:0C) [18:37:48:299]: Note: 1: 1715 2: TestApp 2.0.0   
MSI (s) (F4:0C) [18:37:48:299]: Note: 1: 2262 2: Error 3: -2147287038   
MSI (s) (F4:0C) [18:37:48:299]: Calling SRSetRestorePoint API. dwRestorePtType: 0, dwEventType: 102, llSequenceNumber: 0, szDescription: "Installed TestApp 2.0.0".  
MSI (s) (F4:0C) [18:37:48:299]: The System Restore service is disabled. Returned status: 1058. GetLastError() returned: 1058  
MSI (s) (F4:0C) [18:37:48:299]: Server not locked: locking for product {GUID of 2.0.0}  
Action ended 18:37:48: InstallInitialize. Return value 1.  
MSI (s) (F4:0C) [18:37:48:845]: Doing action: RemoveExistingProducts  
MSI (s) (F4:0C) [18:37:48:845]: Note: 1: 2205 2:  3: ActionText   
Action start 18:37:48: RemoveExistingProducts.  
MSI (s) (F4:0C) [18:37:48:845]: Note: 1: 2262 2: Error 3: -2147287038   
MSI (s) (F4:0C) [18:37:48:845]: Note: 1: 2262 2: Error 3: -2147287038   
...  
Action start 18:37:48: InstallFinalize.  
...  
MSI (s) (F4:AC) [18:37:48:939]: Verifying accessibility of file: start.vbs  
MSI (s) (F4:AC) [18:37:48:939]: Note: 1: 2318 2:    
MSI (s) (F4:AC) [18:37:48:939]: Note: 1: 2318 2:    
...  
Action ended 18:37:48: InstallFinalize. Return value 1.  
MSI (s) (F4:AC) [18:37:48:939]: Doing action: LaunchApplication  
MSI (s) (F4:AC) [18:37:48:939]: Note: 1: 2205 2:  3: ActionText   
Action start 18:37:48: LaunchApplication.  
MSI (s) (F4:AC) [18:37:48:939]: Creating MSIHANDLE (9) of type 790542 for thread 8108  
MSI (s) (F4:B0) [18:37:48:939]: Invoking remote custom action. DLL: C:\Windows\Installer\MSIECB.tmp, Entrypoint: WixShellExec  
MSI (s) (F4:24) [18:37:48:939]: Generating random cookie.  
MSI (s) (F4:24) [18:37:48:939]: Created Custom Action Server with PID 8596 (0x2194).  
MSI (s) (F4:48) [18:37:48:970]: Running as a service.  
MSI (s) (F4:48) [18:37:48:970]: Hello, I'm your 32bit Impersonated custom action server.  
MSI (s) (F4!74) [18:37:49:001]: Creating MSIHANDLE (10) of type 790541 for thread 1140  
MSI (s) (F4!74) [18:37:49:001]: Creating MSIHANDLE (11) of type 790531 for thread 1140  
MSI (s) (F4!74) [18:37:49:001]: Closing MSIHANDLE (11) of type 790531 for thread 1140  
MSI (s) (F4!74) [18:37:49:001]: Creating MSIHANDLE (12) of type 790531 for thread 1140  
WixShellExec:  Error 0x80070002: ShellExec failed with return code 2  
MSI (s) (F4!74) [18:37:49:001]: Closing MSIHANDLE (12) of type 790531 for thread 1140  
MSI (s) (F4!74) [18:37:49:017]: Creating MSIHANDLE (13) of type 790531 for thread 1140  
WixShellExec:  Error 0x80070002: failed to launch target  
MSI (s) (F4!74) [18:37:49:017]: Closing MSIHANDLE (13) of type 790531 for thread 1140  
MSI (s) (F4!74) [18:37:49:017]: Closing MSIHANDLE (10) of type 790541 for thread 1140  
CustomAction LaunchApplication returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)  
MSI (s) (F4:B0) [18:37:49:017]: Closing MSIHANDLE (9) of type 790542 for thread 8108  
Action ended 18:37:49: LaunchApplication. Return value 3.  
Action ended 18:37:49: INSTALL. Return value 3.  
...  
Property(N): WixShellExecTarget = [#start.vbs]  
...  
CustomAction  returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)  
MSI (s) (F4:0C) [18:37:49:017]: Note: 1: 2262 2: Error 3: -2147287038   
MSI (s) (F4:0C) [18:37:49:017]: Note: 1: 2262 2: Error 3: -2147287038   
Action ended 18:37:49: RemoveExistingProducts. Return value 3.  
MSI (s) (F4:0C) [18:37:49:017]: User policy value 'DisableRollback' is 0  
MSI (s) (F4:0C) [18:37:49:017]: Machine policy value 'DisableRollback' is 0  
MSI (s) (F4:0C) [18:37:49:017]: Executing op: Header(Signature=1397708873,Version=500,Timestamp=1190565049,LangId=1033,Platform=0,ScriptType=2,ScriptMajorVersion=21,ScriptMinorVersion=4,ScriptAttributes=0)  
MSI (s) (F4:0C) [18:37:49:017]: Executing op: DialogInfo(Type=0,Argument=1033)  
MSI (s) (F4:0C) [18:37:49:017]: Executing op: DialogInfo(Type=1,Argument=TestApp 1.0.0)  
MSI (s) (F4:0C) [18:37:49:017]: Executing op: RollbackInfo(,RollbackAction=Rollback,RollbackDescription=Rolling back action:,RollbackTemplate=[1],CleanupAction=RollbackCleanup,CleanupDescription=Removing backup files,CleanupTemplate=File: [1])  
MSI (s) (F4:0C) [18:37:49:017]: Executing op: SetTargetFolder(Folder=C:\Users\user1\AppData\Local\Programs\TestManufacturer\TestApp 1.0.0\)  
MSI (s) (F4:0C) [18:37:49:017]: Executing op: FileCopy(SourceName=C:\Config.Msi\1bc1cc05.rbf,,DestName=C:\Users\user1\AppData\Local\Programs\TestManufacturer\TestApp 1.0.0\start.vbs,Attributes=40992,FileSize=331,PerTick=0,,VerifyMedia=0,ElevateFlags=1,,,,,,,InstallMode=4194308,,,,,,,)  
MSI (s) (F4:0C) [18:37:49:017]: File: C:\Users\user1\AppData\Local\Programs\TestManufacturer\TestApp 1.0.0\start.vbs;   To be installed;    Won't patch;    No existing file  
...  
MSI (s) (F4:0C) [18:37:49:126]: Executing op: End(Checksum=0,ProgressTotalHDWord=0,ProgressTotalLDWord=0)  
MSI (s) (F4:0C) [18:37:49:126]: Error in rollback skipped.  Return: 5  
MSI (s) (F4:0C) [18:37:49:126]: No System Restore sequence number for this installation.  
MSI (s) (F4:0C) [18:37:49:126]: Unlocking Server  
MSI (s) (F4:0C) [18:37:49:173]: Note: 1: 2205 2:  3: Control   
Action ended 18:37:49: INSTALL. Return value 3.  
...  
MSI (s) (F4:0C) [18:37:49:173]: MainEngineThread is returning 1603  
MSI (s) (F4:78) [18:37:49:173]: RESTART MANAGER: Session closed.  
MSI (s) (F4:78) [18:37:49:173]: RESTART MANAGER: Session closed.  
MSI (s) (F4:78) [18:37:49:173]: No System Restore sequence number for this installation.  
MSI (s) (F4:78) [18:37:49:173]: User policy value 'DisableRollback' is 0  
MSI (s) (F4:78) [18:37:49:173]: Machine policy value 'DisableRollback' is 0  
MSI (s) (F4:78) [18:37:49:173]: Incrementing counter to disable shutdown. Counter after increment: 0  
MSI (s) (F4:78) [18:37:49:173]: Note: 1: 1402 2: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\Rollback\Scripts 3: 2   
MSI (s) (F4:78) [18:37:49:173]: Note: 1: 1402 2: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\Rollback\Scripts 3: 2   
MSI (s) (F4:78) [18:37:49:189]: Decrementing counter to disable shutdown. If counter >= 0, shutdown will be denied.  Counter after decrement: -1  
MSI (s) (F4:78) [18:37:49:189]: Restoring environment variables  
MSI (s) (F4:78) [18:37:49:189]: Destroying RemoteAPI object.  
MSI (s) (F4:24) [18:37:49:189]: Custom Action Manager thread ending.  
MSI (c) (A8:A4) [18:37:49:189]: Back from server. Return value: 1603  
MSI (c) (A8:A4) [18:37:49:189]: Decrementing counter to disable shutdown. If counter >= 0, shutdown will be denied.  Counter after decrement: -1  
MSI (c) (A8:A4) [18:37:49:189]: PROPERTY CHANGE: Deleting SECONDSEQUENCE property. Its current value is '1'.  
Action ended 18:37:49: ExecuteAction. Return value 3.  
Action ended 18:37:49: INSTALL. Return value 3.  
...  
=== Logging stopped: 7/22/2015  18:37:49 ===  
MSI (c) (A8:A4) [18:37:49:189]: Note: 1: 1708   
MSI (c) (A8:A4) [18:37:49:189]: Note: 1: 2262 2: Error 3: -2147287038   
MSI (c) (A8:A4) [18:37:49:189]: Note: 1: 2262 2: Error 3: -2147287038   
MSI (c) (A8:A4) [18:37:49:189]: Product: TestApp 2.0.0 -- Installation failed.  

据我了解,问题的根本原因是我没有在自定义操作 LaunchApplication 中使用“未安装且未升级产品代码”条件。

 <Custom Action="LaunchApplication" After="InstallFinalize">NOT Installed AND NOT UPGRADINGPRODUCTCODE</Custom>

在这种情况下,安装程序在安装新版本期间会删除旧版本,然后尝试从旧版本运行自定义操作 LaunchApplication,但所有文件都已被删除。这就是安装失败的原因。
我在 LaunchApplication 中添加了条件“未安装且未升级产品代码”,现在可以对我的应用程序进行重大升级。
但我不确定我应该使用哪种条件 - “未安装且未升级产品代码”或“未安装”。
我需要在首次安装和所有主要升级期间运行自定义操作 LaunchApplication。

【问题讨论】:

    标签: wix windows-installer


    【解决方案1】:

    不确定这是一个答案,但评论太多了。

    首先,使用详细日志记录进行升级,使用 /L*vx 的 msiexec.exe 命令查看发生了什么,因为有很多事情没有意义。

    1. 您的自定义操作是在 InstallFinalize 之后,这意味着它是在安装完成并提交之后,因此不会导致升级失败。

    2. 您的 RemoveExistingProducts 在 InstallInitialize 之前。这意味着它位于从 InstallInitialize 开始的安装事务之外。它确实需要在 InstallInitialize 之后才包含在事务中,因为目前它独立于您的新产品安装,因此您可以获得删除失败或工作以及安装失败或工作的任意组合,您最终可以得到您系统上的一组不确定的产品。没有,没有或其中之一。

    3. 什么是 SELFFOUND?我希望升级元素可以引用它,但没有。一般来说,如果您想阻止安装具有相同版本的主要升级,您应该查看 MajorUpgrade 元素并将 AllowSameVersionUpgrades 等属性设置为 No。如果 SELFFOUND 旨在防止两次安装相同的 MSI 文件,请不要打扰,因为 Windows 无论如何都不会让您这样做。

    所以没有足够的信息来了解发生了什么,但 CA 不能对此负责。最可能的解释是第一次升级失败 - 它删除了旧产品,然后您的新安装失败,并且由于删除在事务之外,您所看到的只是删除工作并且您的安装失败。当您再次安装时,它是一个全新的系统,这就是主要区别。检查日志!

    【讨论】:

    • 你能检查我的更新吗?我认为问题的根本原因是我没有在自定义操作 LaunchApplication 中使用条件“未安装且未升级产品代码”。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-10-27
    • 1970-01-01
    • 1970-01-01
    • 2015-02-20
    • 1970-01-01
    • 1970-01-01
    • 2012-11-27
    相关资源
    最近更新 更多