简体   繁体   中英

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

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM