[wix-users] Maintain user modified files during upgrade

Brian Enderle brianke at gmail.com
Thu Jan 26 08:03:34 PST 2017


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


More information about the wix-users mailing list