How can I remove an config file on uninstall when software uses major upgrades, @neveroverwrite and @permanent

72 views Asked by At

Major Upgrades and config files are common component parts of an software.

Declaration for the major upgrades:

<MajorUpgrade DowngradeErrorMessage="A newer version of $(var.AppName) is already installed." AllowSameVersionUpgrades="yes" /> 

While doing major upgrades, a config file should not be removed and not be overwritten. The config file hast to stay. That is realized with the following declaration:

<Component Id="MyConfigComponent" NeverOverwrite="yes" Permanent="yes" Guid="MY-GUID-HERE">
    <File Id="MyConfigOutput" KeyPath="yes" Name="MyConfig.config" Source="..\MyApp\MyConfig.config.bak"/>
</Component>

How can I remove the file MyConfig.config on uninstall?

Using a declaration like <RemoveFile On="uninstall" Name="MyConfig.config" ... > removes the config file on an Upgrade. Therefore, it cannot be used for this purpose. The same applies to RemoveFolderEx. What have I to use instead?

1

There are 1 answers

0
jbudreau On

You have to write a custom action to manually delete the file/directory and schedule it to execute under the condition "$config_file_component=2 And Not UPGRADINGPRODUCTCODE". This will fire the custom action when the config file component is getting removed (during an uninstall or a modify) but not as a part of the uninstall process during an upgrade.