Quantcast
Channel: wixsharp Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1354

New Post: Force update for unversioned files

$
0
0
As with many other non primary attributes CompanionFile can be set via AttributeDefinition:
new File(@"Files\Docs\Manual.txt")
{
    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 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);
    }
}
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 repair/reinstall).

Viewing all articles
Browse latest Browse all 1354

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>