0

I have two work modes in my installer:

  1. use config files left from previous installation
  2. delete all existing configs and put default configs instead

The mode is determined by the checkbox in the WPF UI of the installer. If second mode is selected, then CustomAction is run, which manually deletes the configs folder from disk:

<InstallExecuteSequence>
  <Custom Action="RemoveConfigsFolder" After="RemoveFolders" Overridable="yes">NOT Installed AND DELETESETTINGS=1</Custom>      
</InstallExecuteSequence>

I'm using NeverOverwrite attribute:

<ComponentGroup Id="Configs" Directory="INSTALLDIR" >
  <Component Id="Configs" Permanent="yes"   NeverOverwrite="yes">
    <File Id="main.config" Name="main.config" Source=".\Configs\main.config" KeyPath="yes" />
  </Component>
</ComponentGroup>

The first mode works fine in this case, but when I try to use second mode it fails and all configs are just deleted and never created again during the installation.

During my research of the issue, I think I've found the reason why this happens: https://community.flexerasoftware.com/showthread.php?96157-The-truth-the-whole-truth-about-quot-Never-overwrite-quot-and-quot-Permanent-quot-files&p=156826#post156826

Actually this is a Windows Installer issue. If you log the uninstall you will notice that very early in the installation the Installer decides that the component containing this file will not be installed because it is marked "Never Overwrite" and a copy of this file already exists on the target machine. The uninstall happens after that which removes the existing file. This is because the Installer decides this when the "CostFinalize" action is launched. This action HAS to be run before the "RemoveFiles" action.

But how do I fix it?

1
  • Is this a major upgrade situation, and, if so, where is it scheduled? Commented Jun 15, 2017 at 18:04

2 Answers 2

3

The problem with settings such as Never Overwrite or Permanent is they look like build settings, but they are not really - they stick to the system attached to the component id. So resetting in the project won't help because it's associated with that id. It's also not clear why setting Never Overwrite might have been a solution to some problem, because by definition patches and overwrite upgrades won't overwrite it, but overwriting it is a requirement of your setup.

Even if you had not set Never Overwrite the Windows Installer rules would not overwrite the file if it was modified after install. So if you had installed it, then it was altered, and then you did an upgrade, the file would not be overwritten (which is another reason why Never Overwrite does not seem needed).

Another issue is that your custom action RemoveConfigsFolder is not marked with an Execute enumeration value, therefore it is immediate, therefore it does not run elevated, therefore it might simply be failing, so without seeing the code it's impossible to say if reports an issue if it can't do the remove. It's also not possible to determine if it explicitly specifies the full path to the folder correctly. So the most likely quick fix to this issue is to mark the custom action as execute deferred, and the DELETESETTINGS value will need to be passed in via CustomActionData.

Sign up to request clarification or add additional context in comments.

1 Comment

The problem is, I'm not always upgrading. Sometimes it's uninstalling and installing afterwards. As far as I understand, Windows Installer rules work another way in this case, and they will overwrite the file even if it was modified after install. This is the situation where I need to use Never Overwrite.
0

My initial thought is to remove the 'Never Overwrite' property. Then create a component condition that checks if the file exists. My thought is that your custom action has the condition to correctly remove the config files. If the files do not exist then the components will be selected for install.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.