5
votes

I'm in the process of upgrading an old Visual Studio setup project installer to a WiX installer.

I have a problem with the new installer though - it keeps removing a config file that was installed with the old installer.

The component in the .wxs file looks like this:

<Component Id="MyConfig" NeverOverwrite="yes" Permanent="yes">
  <File Id="MyApp.exe.config" Name="MyApp.exe.config" />
</Component>

I tried setting the component Id and Guid to the same as they were in the old installer, but then it replaces the existing config file with the new one - which I don't want, as the config file may have been modified since the initial installation.

What I want, is if MyApp.exe.config is already installed it should not be removed or replaced.

1
@Erti-ChrisEelmaa it's not a duplicate. In my case it works fine when doing a major upgrade with the WiX installers. My issue is only when upgrading an older installer's installation with the WiX installers.Cocowalla

1 Answers

6
votes

Make sure your RemoveExistingProducts is scheduled after InstallExecute, eg: afterInstallExecute. GUID and Keypath of the component need to be the same as they were in your previous installer. MSI will only overwrite the old config file if it's modified date is equal to its create date. If the modified date is after the create date the config file was modified and MSI will not overwrite. You shouldn't need the Permanent attribute, that makes this file leaked on uninstall. Don't use NeverOverwrite either: per the docs this is only for registry.