我正在寻找一种方法来防止我的应用程序降级.但“问题”是,我必须检查修订号
例如:
安装1.0.0.1时应该可以安装1.0.0.2 – 但是安装1.0.0.2时不应该安装1.0.0.1.
我知道,Element MajorUpgrade只检查前三个令牌.
也许有人可以给我一个想法,怎么做?我可以写一个CustomAction来做到这一点吗? – 如果是,我如何检查CustomAction应该安装哪个版本以及安装了哪个版本?
我在哪里调用CustomAction,如何显示消息并阻止从CustomAction安装?
这是一个常见的要求.经常使用以下模式:
<Upgrade Id="THE-PRODUCT-GUID"> <UpgradeVersion Property="PREVIOUSVERSIONINSTALLED" Minimum="1.0.0.0" Maximum="$(var.packageVersion)" IncludeMinimum="yes" IncludeMaximum="no" MigrateFeatures="yes" /> IncludeMinimum="yes" IncludeMaximum="yes" /> <UpgradeVersion Property="NEWERVERSIONINSTALLED" Minimum="$(var.packageVersion)" Maximum="99.0.0.0" IncludeMinimum="no" IncludeMaximum="yes" /> </Upgrade> <InstallExecuteSequence> <Custom Action="PreventDowngrading" After="FindRelatedProducts">NEWERVERSIONINSTALLED<>"" AND NOT Installed</Custom> <RemoveExistingProducts After="InstallInitialize">PREVIOUSVERSIONINSTALLED<>""</RemoveExistingProducts> </InstallExecuteSequence>
PreventDowngrading自定义操作本质上是一个突破性错误:
<CustomAction Id="PreventDowngrading" Error="Newer version already installed." />