faujong
faujong

Reputation: 1127

revert back to previous version of wix installer

When using Visual Studio Setup project, if an installation fails, it will revert back to the previous version of the installation, so it restored the previous files. But, when using WiX installer, if the installation fails, WiX installer removed all the files on the installed folder. How can I make WiX installer restore the previous files when the installation fails ?

Thank you.

This is in Product.wxs of a Wix installer for a Windows Service:

 <Product Id="*" Name="WixWindowsService2012" Language="1033" Version="1.0.0.1" Manufacturer="aaa" UpgradeCode="blabla">
 <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine"   Platforms="x64"/>
 <Upgrade Id="blabla">
 <UpgradeVersion OnlyDetect="no" Property="PREVIOUSFOUND" 
    Minimum="1.0.0.0"  IncludeMinimum="yes" 
    Maximum="99.0.0.0" IncludeMaximum="no" />
 </Upgrade>
 <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
 <MediaTemplate />
 <Feature Id="ProductFeature" Title="WixWindowsService2012" Level="1">
    <ComponentGroupRef Id="ProductComponents" />
 </Feature>
 </Product>
  : 
 <Component Id="ProductComponent" Win64="yes">
 <File Id="WixWindowsService2012.exe" Name="WixWindowsService2012.exe"     Source="$(var.WixWindowsService2012.TargetPath)" Vital="yes" KeyPath="yes" DiskId="1"/>
 <ServiceInstall 
  Id="ServiceInstaller" 
  Type="ownProcess" 
  Vital="yes" 
  Name="WixWindowsService2012" 
  DisplayName="WixWindowsService2012" 
  Description="A test for WiX installation for Windows Service" 
  Start="auto" 
  Account="LocalSystem" 
  ErrorControl="ignore" 
  Interactive="no"></ServiceInstall>
  <ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="WixWindowsService2012" Wait="yes" />
  </Component>

Upvotes: 2

Views: 817

Answers (1)

PhilDW
PhilDW

Reputation: 20780

If you had a setup that restored previous versions of the files then by definition it was an upgrade (RemovePreviousVersions in Visual Studio). In WiX you specify an upgrade by using the MajorUpgrade element, so whatever you have in yours isn't sufficient or isn't working. Your UpgradeCode in the WiX project needs to be the same as your previous setup, whether it's WiX or VS. The ProductVersion must be incremented in the first 3 digits, and the ProductCode must be different. In addition, a per-machine install will not upgrade a per user install, just in case that's happening. Creating a verbose log of the install will supply the reason why your upgrade isn't working.

Upvotes: 1

Related Questions