6

Hi I am installing files into a directory using WIX with the code below.

 <Directory Id="CMSICONSDIR" Name="CMSIcons">
    <Component Id="CMSICONSDIR_C" Guid="B0328FBF-D9F7-4278-B16C-28650016FF86" SharedDllRefCount="no" KeyPath="no" NeverOverwrite="no" Permanent="no" Transitive="no" Location="either">
       <CreateFolder/>
       <File Id="AddCamera.png" Name="AddCamera.png" DiskId="1" Source="..\..\OrionVEWorld\bin\Release\CMSICons\AddCamera.png" KeyPath="no"  />
       <File Id="aldownloadsmall.png" Name="al-download-small.png" DiskId="1" Source="..\..\OrionVEWorld\bin\Release\CMSICons\al-download-small.png" KeyPath="no"  /> 

They way my application works is that a user can copy their own files in that directory overriding with what they prefer.

The problem is when I do my next install for an update, its overrides those files with the files stipulated in the install.

How do I ensure that when I run my install it does not override the existing files that are there and only adds new ones.

Unfortunately in other case I do need files that override what is there.

I do have an upgrade script section which can affect this as below

<Upgrade Id="$(var.UpgradeCode)">
  <UpgradeVersion Minimum="$(var.ProductVersion)" OnlyDetect="no" Property="NEWERVERSIONDETECTED"/>
  <UpgradeVersion Minimum="1.0.0.0"
                  IncludeMinimum="yes"
                  OnlyDetect="no"
                  Maximum="$(var.ProductVersion)"
                  IncludeMaximum="no"
                  Property="PREVIOUSVERSIONSINSTALLED" />
</Upgrade>

Any suggestions is appreciated.

Yan Sklyarenko
  • 31,557
  • 24
  • 104
  • 139
TheWommies
  • 4,922
  • 11
  • 61
  • 79

2 Answers2

5

You could try changing the upgrade order by modifing the sequence of RemoveExistingProducts action. You could place it after InstallFinalize (no 4 option in the link article).

Also this article explains how windows installer handles the whole file overwrite logic.

EDIT: Also add the "Never overwrite" attribute to the components.

Ciprian
  • 3,533
  • 1
  • 18
  • 22
  • Done and did NeverOverwrite="yes" Permanent="yes" in my component and it still overwrites my previous files. Not sure what I am doing wrong – TheWommies Jan 22 '12 at 22:37
2

Try adding NeverOverwrite attribute to your components. It should do the trick.

imagi
  • 946
  • 8
  • 8
  • This is not enough if the RemoveExistingProducts action is before InstallExecute. – Ciprian Jan 20 '12 at 09:55
  • @Ciprian - Doesn't WIX schedule RemoveExistingProducts action after InstallExecute by default? – imagi Jan 20 '12 at 11:54
  • You might be right on this. I don't have extensive knowledge about WIX. – Ciprian Jan 20 '12 at 15:47
  • Another problem is I only want to not override if there is a file already there. When a file is absent I don want that file installed. However it seems when I put NeverOverwrite in my component it also does not install files that are absent – TheWommies Jan 23 '12 at 03:54
  • Old question, but it hasn't been resolved so figured I'd throw my penny in here. According to the documentation, only the KeyPath of the component is checked, so if you have multiple files in the component (like in the question), it will only check the KeyPath file, and skip any other ones if that exists. see: http://wixtoolset.org/documentation/manual/v3/xsd/wix/component.html – Simon Feb 13 '14 at 14:53