0

I use Visual Studio 2015 Setup Project to install my application which supports upgrade. I performed below tasks: 1) I copied test.xml file in program files location through installation 2) I modified test.xml today 3) I perform upgrade for the application where customer requirement is to copy/over write test.xml(no matter it is latest or not) file with package file (assume package file is modified yesterday)

As the existing file is latest than package file, installation is not over-writing the file at all.

Hence, I tried to delete this file in OnBeforeInstall() so that the new file would be copied in OnAfterInstall(). But, unfortunately, installer does call the custom action event handlers after copying files.

Then, I found there is property called

Condition

enter image description here

Which I defined 1 (True) so that irrespective existing file's modification time, installer could over-write the file. But that also didn't work out. Seems like after the condition evaluates to true, still installer applies file time stamp check and it doesn't copy if the existing file is latest.

Hence, please let me know is there any other way to make this work!

PhilDW
  • 20,260
  • 1
  • 18
  • 28
RJN
  • 696
  • 8
  • 17

1 Answers1

1

Some potential solutions to this:

  1. Arrange for your setup to update the existing Xml file if you're doing an upgrade by adding whatever new data is required. Windows Installer won't overwrite updated files - nobody wants to replace a database full of data with an empty DB.

  2. Alter the MSI file (with a tool such as Orca). Go into the InstallExecuteSequence table and move the RemoveExistingProducts action from just before InstallFinalize (when sequenced by Sequence) to immediately after InstallInitialize. This will do a complete uninstall of the older product before installing all the new files, sop make sure that works for all your files.

  3. You could alter the app that updates the Xml file so that after every update (or at least before an upgrade) it sets the creation timestamp of the file to be the same as the modify timestamp. Then Windows Installer will assume that it has not been updated and can therefore be replaced. You can't do this in a custom action because, as you've discovered, in Visual Studio they all run after the files have been installed.

  4. Don't use the installed Xml file in the application. Add some logic to the application that uses the Xml file as a template, and at first run copies it somewhere, and then the copy is the actual file that's used. The install can then overwrite the unaltered file, and the app can again make a copy and use that.

PhilDW
  • 20,260
  • 1
  • 18
  • 28
  • Awesome tips! thanks much. I used tip.2 and found its working. But one concern is every time, I need to modify the MSI file before I handover to customer! I changed sequence No of RemoveExistingProducts to come next to InstallInitialize, hope thats how we need to do. – RJN Apr 03 '18 at 07:04
  • I couldn't use Tip-1 because most of the time, I don't have any modification in XML file. Even if I introduce version number or something and keep modifying for every build there is no chance that customer use my build immediately after my release OR I don't have control to stop them not to modify XML files after my build. Due to this reason, I couldn't use Tip-3 as well. Tip-4 could you elaborate, I couldn't get it – RJN Apr 03 '18 at 07:09