如何区分WIX中的正常安装和升级?

Sli*_*ppy 9 .net wix wix3.5

我有一些自定义操作,我只想在升级方案中执行.

我正在尝试设置一些属性,例如"MYPROPERTY"......当我通过标准安装进入时,我可以设置它们,并且该XML的示例如下...

<Custom Action="SetMyPropertyToOn" After="exampleActionRuuningBeforeThisOne"> (ENABLEMYPROPERTY_CB) AND (NOT ENABLEMYPROPERTY_CB="0") AND (NOT ENABLEMYPROPERTY) AND (NOT Installed)</Custom>
Run Code Online (Sandbox Code Playgroud)

它在正常安装中运行...我也希望它在升级方案中运行.

Nat*_*arr 23

我在所有设置中都使用它:

    <SetProperty After="FindRelatedProducts" Id="FirstInstall" Value="true">
        NOT Installed AND NOT WIX_UPGRADE_DETECTED AND NOT WIX_DOWNGRADE_DETECTED
    </SetProperty>
    <SetProperty After="SetFirstInstall" Id="Upgrading" Value="true">
        WIX_UPGRADE_DETECTED AND NOT (REMOVE="ALL")
    </SetProperty>
    <SetProperty After="RemoveExistingProducts" Id="RemovingForUpgrade" Sequence="execute" Value="true">
        (REMOVE="ALL") AND UPGRADINGPRODUCTCODE
    </SetProperty>
    <SetProperty After="SetUpgrading" Id="Uninstalling" Value="true">
        Installed AND (REMOVE="ALL") AND NOT (WIX_UPGRADE_DETECTED OR UPGRADINGPRODUCTCODE)
    </SetProperty>
    <SetProperty After="SetUninstalling" Id="Maintenance" Value="true">
        Installed AND NOT Upgrading AND NOT Uninstalling AND NOT UPGRADINGPRODUCTCODE
    </SetProperty>
Run Code Online (Sandbox Code Playgroud)

然后,您可以将自定义操作安排为仅在升级时运行:

<Custom Action="NameOfCustomAction" Before="InstallFinalize"><![CDATA[Upgrading= "true"]]></Custom>
Run Code Online (Sandbox Code Playgroud)

  • WIX_UPGRADE_DETECTED和WIX_DOWNGRADE_DETECTED属性假定使用了MajorUpgrade元素.用户定义的升级规则可能具有不同的ActionProperty名称,而次要升级则根本不具备这些名称.OP没有说他正在做什么样的升级*. (5认同)
  • 经测试,似乎工作正常,但是当您未安装所有功能并再次启动安装程序以选择“删除”选项时,两次运行期间“维护”标志都为 ON。但是,我希望第二次运行时“卸载”打开。“卸载”条件失败,因为 REMOVE &lt;&gt; “ALL”,它等于已安装功能的列表。 (2认同)