当用户将功能从“选定”更改为“未选定”时如何执行自定义操作?

问题描述 投票:0回答:1

如果用户取消选择特定功能,我想执行我的自定义操作。无论是在

Repair
Upgrade
Uninstall
期间,都没关系。 在升级过程中重新安装该功能时,不应执行该操作。 根据我的研究:

操作条件

条件语句语法属性表_UPGRADE 属性仅在卸载时执行操作,不在修复、升级或安装时执行操作 我得出这个解决方案:

_UNINSTALLONLY 属性,有助于仅在卸载时执行自定义操作:

<SetProperty Id="_UNINSTALLONLY" After="FindRelatedProducts" Value="1"> <![CDATA[Installed AND NOT UPGRADINGPRODUCTCODE]]></SetProperty>

还有我的
InstallExecuteSequence

中的延迟自定义操作:

<Custom Action="HandleMyFeatureMyCustomActionOnUnselect" Before="InstallFinalize">
  <![CDATA[_UNINSTALLONLY AND (!MyFeature >= 2) AND (&MyFeature <= 2) ]]></Custom>

这有效,
当用户取消选择升级功能时

。然后该操作被调用。 我尝试过:

(!MyFeature >= 2) AND (&MyFeature <= 2)

:问题:升级时调用操作,

即使用户不更改选择

_UNINSTALLONLY AND (&MyFeature <= 2)

:问题:当我取消选择升级时的

另一个功能2
时,也会调用操作 现在我感觉有点失落。

另一个要求是,在产品升级过程中,旧版本必须被可靠地删除。此外,根据功能在设置中的当前状态预先选择功能也很重要。我已经成功地实现了这一点。 为了排除与我的问题的任何交互,这里有一些额外的背景信息:

<CustomAction Id="HandleMyFeatureMyCustomActionOnUnselect" BinaryKey="FeatureCustomActions" DllEntry="HandleMyFeatureMyCustomActionOnUnselect" Impersonate="no" Execute="deferred" Return="check" /> <CustomAction Id="SetHandleMyFeatureMyCustomActionOnUnselectPropertyValues" Property="HandleMyFeatureMyCustomActionOnUnselect" Value="INSTALLFOLDER=[INSTALLFOLDER]" /> <Property Id='INSTALLFEATURE'> <RegistrySearch Id='InstallFEATURE' Root='HKLM' Key='SOFTWARE\Somewhere\AnotherKey' Name='FEATUREINSTALLED' Type='raw' /> </Property>

InstallExecuteSequence

<InstallExecuteSequence>
   <Custom Action="SetREINSTALL" Before="CostInitialize">
            Installed AND REMOVE ~= "" AND NOT REINSTALL
   </Custom>
   <RemoveExistingProducts After="InstallInitialize"/>
   ...
   <Custom Action="SetHandleMyFeatureMyCustomActionOnUnselectPropertyValues" Before="HandleMyFeatureMyCustomActionOnUnselect" ><![CDATA[_UNINSTALLONLY AND (!MyFeature >= 2) AND (&MyFeature <= 2) ]]></Custom>
   <Custom Action="HandleMyFeatureMyCustomActionOnUnselect" Before="InstallFinalize"><![CDATA[_UNINSTALLONLY AND (!MyFeature >= 2) AND (&MyFeature <= 2) ]]></Custom>
   ...
</InstallExecuteSequence>

Features

<Feature Id="MyFeature" Title="My Feature" ConfigurableDirectory="INSTALLFOLDER"  Display="expand" Level="1">
    <Condition Level="2">INSTALLFEATURE=0</Condition> 
    <ComponentGroupRef Id="FEATURE"/>
</Feature>
<Feature Id="MyFeature2" Title="My Feature2" ConfigurableDirectory="INSTALLFOLDER"  Display="expand" Level="1">
    <Condition Level="2">INSTALLFEATURE2=0</Condition> 
    <ComponentGroupRef Id="FEATURE2"/>
</Feature>

所以我的问题是:
当用户将功能从“选定”更改为“未选定”时,如何执行自定义操作?


我解决了它,与
wix windows-installer custom-action wix3
1个回答
0
投票
<SetProperty Id="_NEWINSTALLER" After="FindRelatedProducts" Value="1"> <![CDATA[NOT UPGRADINGPRODUCTCODE]]></SetProperty>

以及条件
<Custom Action="SetHandleMyFeatureMyCustomActionOnUnselectPropertyValues" Before="HandleMyFeatureMyCustomActionOnUnselect" >
    <![CDATA[_NEWINSTALLER AND (!MyFeature >= 2) AND (&MyFeature <= 2) ]]></Custom>
<Custom Action="HandleMyFeatureMyCustomActionOnUnselect" Before="InstallFinalize">
    <![CDATA[_NEWINSTALLER AND (!MyFeature >= 2) AND (&MyFeature <= 2) ]]>
</Custom>

我太接近了!现在正在接受测试:-)
    

© www.soinside.com 2019 - 2024. All rights reserved.