I am searching a way to prevent a downgrade of my application. But the "problem" is, that I have to check the revision-number
for example: it should be possible to install 1.0.0.2 when 1.0.0.1 is installed - but it should not be possible to install 1.0.0.1 when 1.0.0.2 is installed.
I know, that the Element MajorUpgrade only check the first three tokens. Perhaps someone can give me an idea, how to do this? Can I wrote a CustomAction to do this? - When yes, how can I check in the CustomAction which version should be installed and which version is installed? Where does I have to call the CustomAction and how can I show a message and prevent installing from the CustomAction?
This is a common requirement. The following pattern frequently used:
<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
custom action is essentially a breaking error:
<CustomAction Id="PreventDowngrading" Error="Newer version already installed." />