As with many other non primary attributes
Though as for me, I wouldn't go this way. To be honest I even found the whole concept of something being installed, then overwritten by user, then replaced by the upgrade is questionable. It seems like a better separation between default and user specific settings is what your solution is lacking. MSI is a deployment solution so it only should be concerned about the delivery of the files but not about making any decisions regarding their content fate.
Anyway, if I really need to implement your requirement I would rather use something more manageable than MSI/WiX:
This way there is a clear separation of concerns and you can also decide if you want to preserve some of the user settings.
You can even abort the settings overwriting completely (e.g. during
CompanionFile
can be set via AttributeDefinition
:new File(@"Files\Docs\Manual.txt") { AttributesDefinition = "CompanionFile=<whatever_value_you_need>" }),
Anyway, if I really need to implement your requirement I would rather use something more manageable than MSI/WiX:
var project = new Project("MyProduct", new Dir(@"%ProgramFiles%\My Company\My Product", new File(@"Files\Bin\MyApp.exe"), new File(@"Files\Bin\MyApp.exe.config.default"), ... project.AfterInstall += project_AfterInstall; ... staticvoid project_AfterInstall(SetupEventArgs e) { if (e.IsInstalling) { // do any comprehensive analysis herestring defaultConfig = Path.Combine(e.e.InstallDir, "MyApp.exe.config.default"); string userConfig = Path.Combine(e.e.InstallDir, "MyApp.exe.config"); File.Copy(defaultConfig, userConfig, true); } }
You can even abort the settings overwriting completely (e.g. during
repair
/reinstall
).