[wix-users] Maintain user modified files during upgrade

Tyler Gustafson tgustafson at solacom.com
Thu Jan 26 08:23:12 PST 2017


Take a look here:
http://wixtoolset.org/documentation/manual/v3/xsd/wix/majorupgrade.html

My major upgrade element looks like this
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." Schedule="afterInstallExecute" />

Scheduling afterInstallExecute means that during a major upgrade, your new product will be installed and then anything no longer needed will be removed as opposed to the default where it first removes your product including user modified config files and then installs the new version clean.

There are pitfalls to this, mostly if you break component rules. I think there is a link on that page about them.

The other gotchas I've found with this method are if you allow the user to change the installation path with your upgrade and they do change it, you won't get your config files moved over. To get around that one I don't allow changing the install location on an upgrade.
I've also found that if I'm doing my major upgrade in a burn bundle with other upgrades and an upgrade further down the chain fails, it will "roll back" the major upgrade of the products that succeeded before it and by roll back I mean remove. I haven't fully decided how to handle that scenario yet. I'm considering making my config file components permanent to avoid them being erased but I would like an uninstall to kill them off. I'm also planning to play with rollback boundaries in the bundle.

If you don't care about an uninstall not removing your config files you might just consider using the Permanent element. I think that works without changing the schedule of your major upgrade element.
<Component Id="Test.exe.config" Guid="SOMEGUID" NeverOverwrite="yes" Permanent="yes">


-----Original Message-----
From: wix-users [mailto:wix-users-bounces at lists.wixtoolset.org] On Behalf Of Brian Enderle
Sent: January-26-17 11:04 AM
To: WiX Users <wix-users at lists.wixtoolset.org>
Subject: [wix-users] Maintain user modified files during upgrade

I am having an issue with maintaining user modified configuration files when I do a major upgrade.  The files are stored in the respective ProgramData folder and each is in its own @Component group:


  <Fragment>
    <ComponentGroup Id="ConfigFiles" Directory="CONFIG_FOLDER">
      <Component Id="Config.xml">
        <File Id="ConfigXML"
              Source="$(var.myProject.TargetDir)config\config.xml"
              Vital="yes"
              KeyPath="yes" />
      </Component>
</Fragment>

I have found this article
:

https://www.joyofsetup.com/2010/01/16/major-upgrades-now-easier-than-ever/

but implementing this solution does NOT maintain my user modified files.

Can someone explain how to maintain user modified files during a major upgrade?



Here is the remaining portion of my installer @Product section in case it
helps:

<!-- Update Guid when releasing a new version of the installer -->
<!-- '*' wildcard ensures a unique GUID on each build --> <?define Guid = "*"?> <?define UpgradeCode = "{8BE68ECB-3D83-4CD0-BB88-77FC62766A89}"?>
<?define BackupConfigGuid = "{C6711A27-7938-4784-97E7-0D11F2C9263D}"?>
<?define BackupMappingGuid = "{03CD7A28-9D35-4129-9B0B-FFEC87F82C4B}"?>

<!-- The following variables are defined here for use throughout the file
     as they cannot be extracted from the EXE (not supported by MSBuild) --> <?define ProductTitle = "My Product Title"?> <?define ProductName = "My Product Name"?> <?define CompanyName = "My Company"?> <?define CompanyLegalName = "My Company, LLC"?>


<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Product Id="$(var.Guid)"
           Name="$(var.ProductTitle) $(var.ShortAssyVersion)"
           Language="1033"
           Version="$(var.LongAssyVersion)"
           Manufacturer="$(var.CompanyLegalName)"
           UpgradeCode="$(var.UpgradeCode)">
    <Package InstallerVersion="300"
             Compressed="yes"
             InstallScope="perMachine"
             InstallPrivileges="elevated"
             Comments="$(var.ProductTitle) $(var.LongAssyVersion)"
             Keywords="Version $(var.LongAssyVersion)"/>

    <!-- "afterInstallValidate" will prevent installer from removing
           existing files that have been modified (i.e., config.xml) -->
    <MajorUpgrade Schedule="afterInstallValidate"
                  DowngradeErrorMessage="A newer version of
$(var.ProductTitle) is already installed." />

    <MediaTemplate EmbedCab="yes" />

    <Feature Id="Complete"
             Title="$(var.ProductTitle) $(var.ShortAssyVersion)"
             Level="1"
             Description="Everything"
             Display="expand"
             ConfigurableDirectory="INSTALL_FOLDER">

      <ComponentRef Id="ProductAppFolderPermssions" />

      <ComponentGroupRef Id="ConfigFiles" />
      <ComponentGroupRef Id="ProductComponents" />

    </Feature>

  </Product>
....



Brian

If you can't explain it simply, you don't understand it well enough.  - Albert Einstein

____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/


More information about the wix-users mailing list