What's the best way to force the update of unversioned files?
I have a set of XML files that have to be updated with any product upgrade, even if the user modified some of them after the previous installation/upgrade. The MSI file versioning rules (https://msdn.microsoft.com/en-us/library/aa368599(v=vs.85).aspx
prevent the update of the modified files in such cases. As far as I understand, using 'Companion Files' (i.e. linking those unversioned XML files to the versions of the exes/dlls) would be the way to go, but I can't find the support for that feature in Wix#.
Any advice please?
Dec 2, 2016 at 1:12 AM
As with many other non primary attributes
can be set via
AttributesDefinition = "CompanionFile=<whatever_value_you_need>"
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:
var project =
new Dir(@"%ProgramFiles%\My Company\My Product",
project.AfterInstall += project_AfterInstall;
static void project_AfterInstall(SetupEventArgs e)
// do any comprehensive analysis here
string 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);
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