2014-02-25 81 views
0

使用Visual Studio安装项目时,如果安装失败,它将恢复到以前版本的安装,因此它恢复了以前的文件。 但是,使用WiX安装程序时,如果安装失败,则WiX安装程序将删除已安装文件夹上的所有文件。 如何在安装失败时让WiX安装程序恢复以前的文件?恢复到以前版本的wix安装程序

谢谢。

这是在维克斯安装为Windows服务的Product.wxs:

<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> 

回答

1

如果你有这样的恢复了以前版本的文件,然后根据定义,这是一个升级(在Visual Studio RemovePreviousVersions的设置)。在WiX中,通过使用MajorUpgrade元素指定升级,因此无论您拥有什么内容都不够用或无法正常工作。您的WiX项目中的UpgradeCode需要与之前的设置相同,无论是WiX还是VS. ProductVersion必须在前3位增加,并且ProductCode必须不同。另外,每台机器安装都不会升级每个用户的安装,以防万一。创建安装的详细日志将提供升级无法正常工作的原因。

+0

感谢您的快速回复。 在下面的MajorUpgrade元素中添加Schedule =“afterInstallInitialize”就是我所需要的。 再次感谢您。 – faujong

相关问题