0

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?

Simon
  • 4,157
  • 2
  • 46
  • 87

1 Answers1

0

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.

jbudreau
  • 1,287
  • 1
  • 10
  • 22