2

I have a similar problem like forki23 by bring Wix to not overwrite a configuration file during upgrade. I have a config file that should not be overwritten during upgrade, but it should be removed during uninstall. However every solution I find, breaks something else.

If I set NoOverwrite=yes and move the RemoveExistingProducts to InstallFinalize the config file is handled as I wished. However, in this case the shortcut is removed during upgrade for some reason. If I leave RemoveExistingProducts at InstallInitialize, the config file is actually removed during upgrade, however the shortcuts are present.

Why is this happening and is there are way to fix it?

<InstallExecuteSequence>
   <RemoveExistingProducts After="InstallInitialize" />
   <!-- InstallInitialize causes config-file to disappear during upgrade -->
   <!-- InstallFinalize causes shortcuts to disappear during upgrade -->

...

<Property Id="DISABLEADVTSHORTCUTS" Value="1" />

...

<Directory Id="INSTALLLOCATION" Name="MyApp">
  <Component Id="MYAPP.EXE" DiskId="1" Guid="...">
    <File Id="MYAPP.EXE" Name="MyApp.exe" Source="..." Vital="yes" KeyPath="yes">
      <Shortcut Id="startmenuShortcut" 
                Directory="ProgramMenuDir" 
                Name="!(loc.ProductName)" 
                WorkingDirectory='INSTALLLOCATION' 
                Icon="Icon.ico" 
                IconIndex="0" 
                Advertise="yes"  />
    </File>
    <RegistryValue Root="HKLM" 
                    Name="InstallLocation" 
                    Key="$(var.InstallLocationRegistryKey)" 
                    Type="string" 
                    Value="[INSTALLLOCATION]">
    </RegistryValue>
  </Component>
  <Component Id="MYAPP.EXE.CONFIG" DiskId="1" Guid="..." NeverOverwrite="yes">
    <File Id="MYAPP.EXE.CONFIG" 
          Name="MyApp.exe.config" 
          Source="..." 
          KeyPath="yes" />
  </Component>
...
</Directory>

...

<Directory Id="ProgramMenuFolder">
    <Directory Id="ProgramMenuDir" Name="!(loc.ProductPrefix)">
        <Component Id="ProgramMenuDir" Guid="...">
            <RegistryValue Root="HKCU" Key="SOFTWARE\MyApp" 
                           Type="string" Value="[INSTALLLOCATION]" KeyPath="yes" />         
            <RemoveFolder Id="ProgramMenuDir" On="uninstall"/>
        </Component>
    </Directory>
</Directory>

Note A: The config-file is a machine-wide configuration and should apply for all users.

Note B: I'm using WiX 3.7 and the target plattform is Windows 7 and 8.

Community
  • 1
  • 1
tseifried
  • 106
  • 1
  • 8
  • Just to let you know a link about where to schedule RemoveExistingProducts...http://jpassing.com/2007/06/16/where-to-place-removeexistingproducts-in-a-major-msi-upgrade/ it might not resolve your problem but at least will help you to understand more about Windows Installer stuff. – Santi Agüero Aug 08 '13 at 13:41

3 Answers3

0

Theoretically "NoOverwrite=yes and move the RemoveExistingProducts to InstallFinalize" should work, but it s clear we are losing something from the big picture. The best method to see why Windows Installer removes the shortcuts is to create a verbose log when launching the upgrade setup. You can do that in a cmd.exe with this command: msiexec /i [msi path] /L*V debug.log

The post the a download link for the log and the GUIDs of the components hosting the shortcuts so we can see if the log helps us understand what happens.

Bogdan Mitrache
  • 10,536
  • 19
  • 34
0

Windows installer works very exact in those things, and if anything gets removed in the After="InstallFinalize" case, this means, that a component has been removed, MSI has thought is not needed, because not contained in your new version of the msi file. Be very sure the GUID of the component containing MYAPP.exe and the shortcut has not changed in your new version. (Compare with a tool like Orce or Insted). It seems it has!

MSI removes only full components, not only shortcuts. Really! Maybe you have an update problem of shortcuts in Windows. Sometimes such things happen. Try to reboot to be sure, that this happens, what you think. Maybe there is an error in your test procedure (or it's the above mentioned GUID problem). There are not many other possibilities, if you have not custom actions which remove shortcuts or you try to add shortcuts as files or such dangerous stuff.

Putting a shortcut in the same component as the .exe is common, but not optimal in my eyes! I recommend to separate resources as much as possible, so put it in an own component. This has advantages, if you later want to rename the shortcut. Then you can just change the GUID of this component and the important .exe file is not touched.

There is a small disadvantage of that, loosing the direct connection to the file version of MYAPP.exe in overinstall scenarios, so if MYAPP.exe is a shared file between several different setups, this is not recommended. Perfect solutions for this are possible, but are not in the focus here.

Philm
  • 3,448
  • 1
  • 29
  • 28
-1

Workaround: If you are still able to change the old (first) msi setup, just mark the component MYAPP.EXE.CONFIG as permanent. Then it will not be uninstalled during Major Upgrade (but not uninstalled at all, what has advantages and disadvantages, in other words, it is mostly acceptable for .config files).

If version 1 of your setup is already shipped, then you could do the same with some tricks too.

Philm
  • 3,448
  • 1
  • 29
  • 28