对于 Wix 工具集和升级版本标签是属性永远重置

问题描述

我们有以下 Product.wxs 的代码。 当安装程序运行后,我们可以看到 BackupFiles 自定义操作运行,但 RestoreFiles 没有运行,如日志文件中所示:

“跳过操作:RestoreFiles(条件为假)”

为什么相同条件下的 BackupFiles 运行而 RestoreFiles 不运行? OLDVERSIONFOUND 是否已更改?


    <?xml version="1.0" encoding="UTF-8"?>
    <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" >
    
    
      <Product Id="*" Name="My Product" Language="1033" Version="0.0.0.0" Manufacturer="MyCompany"
             UpgradeCode="{B55B9CB0-BA28-4BB3-834B-6075AD5D45E4}">
    
        <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
        <UIRef Id="WixUI_ErrorProgresstext" />
    
    
        <!-- Specify UI -->
        <Property Id="WIXUI_INSTALLDIR" Value="INSTALL_FOLDER" />
        <Property Id="RestoreFiles" Value="INSTALL_FOLDER" />
    
    
    <Upgrade Id="{B55B9CB0-BA28-4BB3-834B-6075AD5D45E4}">
      <UpgradeVersion Minimum="1.0.0"
                      IncludeMinimum="yes"
                      OnlyDetect="no"
                      Maximum="0.0.0.0"
                      IncludeMaximum="no"
                      Property="OLDVERSIONFOUND" />
    </Upgrade>    
    
    <InstallExecuteSequence>
    
        <Custom Action="BackupFiles" After="InstallValidate" >OLDVERSIONFOUND</Custom>
        <Custom Action="SetRestoreFiles" Before="RestoreFiles" />
        <Custom Action="RestoreFiles" After="InstallFiles" >OLDVERSIONFOUND></Custom>
    
    
        <RemoveExistingProducts After="InstallInitialize" />    
    
      </InstallExecuteSequence>
    </Wix>

解决方法

并不真正推荐此类自定义操作。 They can be quite complicated to get right。请参阅底部的“设置保留”链接。

简短的版本是设置文件不应该被安装,而是由应用程序根据默认值或模板创建(然后设置永远不会干扰它们),或者您可以云所有设置并在启动时从数据库中检索。 See here,section "cloud-style approaches"


主要升级 - 卸载和安装:主要升级有一个重要的怪异之处。您必须记住,您启动了新安装程序,然后它会启动旧安装程序的卸载序列,作为其自身操作的一部分。 Hence a major upgrade will run the uninstall sequence of your old setup and the install sequence of your new setup(可能根据主要升级设置的配置以不同的顺序排列)。

反直觉效应:这种组合的“安装/卸载”方法会极大地影响逻辑、条件、排序以及属性值 - 有些变化非常反常-直觉的。除了“同时”(或在同一操作期间)运行两个不同版本之外,您还必须记住,每个安装/卸载序列都以两种不同的模式运行:immediate strong>(构建执行脚本)和 deferred(执行脚本执行)。 With poor conditioning the same custom action could run several times unexpectedly (including in the GUI sequence of the launched setup). Confusing. Debug using message boxes as described towards the bottom here

详细解释:尝试在此处详细解释这种复杂性和属性值在安装过程中似乎发生变化的现象:Run Wix Custom action only during uninstall and not during Major upgrade - 请阅读该答案(双源和所有)。晚点回头看,今晚跑测试已经来不及了。


提供一些进一步的链接: