0

In the Product.wxs, I set Schedule="afterInstallInitialize" in the MajorUpgrade so that if the installation fails, it will roll back to the previous version.

Our Windows Service uses app.config that the installer copied to the installed machine. We do this by including the below line in the Product.wxs:

<Component Id="Config" Win64="yes">
        <File Source="$(var.WixWindowsService2012.TargetDir)WixWindowsService2012.exe.config"
              Name="WixWindowsService2012.exe.config"
              Vital="yes" KeyPath="yes" />
</Component>

We only want to copy this app.config file on the first installation, and we do NOT want to copy it in the subsequent installations.

When I comment out the above Component element in the Product.wxs, the installation failed because during installation, it deletes the app.config on the installed folder, and since the Windows Service requires it to run, the installation fails.

How can I make the installation to not copy the app.config to the installed folder if app.config already exists there ?

Thank you.

Frédéric Hamidi
  • 258,201
  • 41
  • 486
  • 479
faujong
  • 949
  • 4
  • 24
  • 40
  • Possible duplicate of [Copy if not exist in WiX](http://stackoverflow.com/questions/1912037/copy-if-not-exist-in-wix). – Frédéric Hamidi Feb 25 '14 at 18:20
  • Following http://stackoverflow.com/questions/1912037/copy-if-not-exist-in-wix, I thought if I set the File element to be like below, it will NOT copy the file if the file already exists in the installed folder: But, the above command still override the file. – faujong Feb 25 '14 at 20:13
  • Was the file modified since the previous installation? – Frédéric Hamidi Feb 25 '14 at 20:26
  • Yes, say the file on the installed folder is 2/25/14 3:41 PM, and the file on the installer is 2/14/15 11:30 am. When I reinstall, the file on the installed folder is overriden by the file on the installer (earlier time). – faujong Feb 25 '14 at 21:58
  • Have you tried `NeverOverwrite="yes"` in `component`? – IlirB Feb 25 '14 at 22:03
  • I added NeverOverwrite="yes" in component, and when I reinstall, the installer first deleted the app.config on the installed folder (from previous installation), and this new installation doesn't copy the file, so the installation fails because the Windows Service can't start without the app.config file. – faujong Feb 25 '14 at 22:21
  • @faujong, the uninstaller part of your setup should not remove the file if its creation and modification dates differ. Is the removal performed by a custom action? – Frédéric Hamidi Feb 26 '14 at 08:08
  • I don't have a custom action to remove any file. This is in Product.wxs: – faujong Feb 26 '14 at 15:19
  • Continuation of the Product.wxs: – faujong Feb 26 '14 at 15:20

1 Answers1

0

The problem is that the RemoveExistingProducts of the upgrade is removing the file, then the incoming upgrade installs the new one, as discussed in the WiX mailing list. RemoveExistingProducts needs to be just before InstallFinalize and after InstallExecute at the end.

PhilDW
  • 20,260
  • 1
  • 18
  • 28
  • When Schedule="afterInstallExecute" or "afterInstallExecuteAgain", the installer CORRECTLY does NOT override the config file. But, when the installation fails, it gave me the prompt "The following applications should be closed before continuing the install: WixWindowsService2012". And, it asks me to select -Automatically close applications and attempt to restart them after setup is complete. -Do not close applications. (A Reboot may be required). – faujong Feb 26 '14 at 20:02
  • Contination of my previous comment: When I select "Automatically close applications and attempt to restart them after setup is complete.", it stop the running Windows Service, but it never prompt me to cancel the installation. So it never rolled back to the previous version of installation. The only way to rollback the installation is when I click Cancel on the above prompt. Is that by design ? – faujong Feb 26 '14 at 20:02