2017-04-04 76 views
0

我正在使用Wix工具集爲我的應用程序生成.msi。當我升級到新版本時,除了每次運行新版本安裝時,一切都可以正常工作,安裝程序不會檢測已安裝的功能,而是默認使用「必需」功能,這意味着如果用戶安裝了任何其他功能除非用戶明確檢查它們再次安裝,否則它們將被刪除。Wix升級msi刪除已安裝的功能

有沒有辦法讓.msi檢測每次安裝新版本時當前安裝了哪些功能?

  <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"> 
      <Product Id="*" UpgradeCode="9e578e3d-0119-425c-8633-f54ffaaa4929" Name="@[email protected]" Version="@[email protected]" Manufacturer="@[email protected]" Language="1033"> 
      <Package InstallerVersion="400" Compressed="yes" InstallScope="perMachine" Comments="@[email protected]" Description="@[email protected]"/> 
      <Media Id="1" Cabinet="myapp.cab" EmbedCab="yes" /> 

      <!-- Installer Properties --> 
      <Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" /> 
      <PropertyRef Id="WIX_IS_NETFRAMEWORK_46_OR_LATER_INSTALLED"/> 

      <!-- Check Existing Install --> 
      <Upgrade Id="9e578e3d-0119-425c-8633-f54ffaaa4929"> 
       <UpgradeVersion Minimum="@[email protected]" OnlyDetect="yes" Property="NEWERVERSIONDETECTED"/> 
       <UpgradeVersion Minimum="0.0.0" Maximum="@[email protected]" IncludeMinimum="yes" IncludeMaximum="no" Property="OLDERVERSIONBEINGUPGRADED"/> 
      </Upgrade> 
      <Condition Message="A newer version of this software is already installed.">NOT NEWERVERSIONDETECTED</Condition> 

      <!-- Prerequisites --> 
      <Condition Message="This application requires .NET Framework 4.6 or newer. Please install the .NET Framework then run this installer again."> 
       <![CDATA[Installed OR WIX_IS_NETFRAMEWORK_46_OR_LATER_INSTALLED]]> 
      </Condition> 

      <Condition Message="This application is only supported on Windows 7, Windows Server 2008 R2 or higher."> 
       <![CDATA[Installed OR (VersionNT >= 601)]]> 
      </Condition> 

    ... 

    <Feature Id="Feature_Application" 
         Title="Application" 
         ConfigurableDirectory="APPLICATIONDIR" 
         Level="1" 
         AllowAdvertise="no"> 
         @[email protected] 
         <ComponentRef Id="ApplicationShortcut" />      
         <ComponentRef Id="CleanupApplicationData" />      
     </Feature> 

     <!-- Feature: My Service --> 
     <Feature Id="Feature_Service" 
         Title="My Service" 
         Description="My Service" 
         ConfigurableDirectory="REPORTDIR" 
         Level="3" 
         AllowAdvertise="no"> 
         @[email protected]  
         <ComponentRef Id="ServiceShortcut" />      
      <Component Id="MyServiceInstaller_ServiceControl" Guid="B72CAA3F-F2DB-48D2-90DD-061209AB2CE5" Directory="REPORTDIR"> 
       <CreateFolder /> 
       <File Id="MyService.exe" Name="MyService.exe" KeyPath="yes" Source="@[email protected]\MyService\MyService.exe"/> 
       <ServiceInstall Id="MyServiceInstaller_ServiceInstall" 
        Type="ownProcess" 
        Vital="yes" 
        Name="Windows Service"      
        DisplayName="Windows Service" 
        Description="Windows service" 
        Start="auto" 
        Account="NT AUTHORITY\LocalService" 
        ErrorControl="ignore" 
        Interactive="no" /> 
       <ServiceControl Id="MyServiceInstaller_ServiceInstall" 
        Name="My Service" 
        Stop="both" 
        Remove="uninstall" 
        Wait="yes" />    
      </Component>  

     </Feature> 

    <InstallExecuteSequence> 
     <RemoveExistingProducts After="InstallValidate"/> 
    </InstallExecuteSequence> 

    <UIRef Id="WixUI_FeatureTree" /> 
    <UI> 
     <DialogRef Id="FilesInUse" /> 
     <DialogRef Id="MsiRMFilesInUse" /> 
     <!-- Add the GUI logic for installation --> 
    </UI> 
    </Product> 
+0

似乎很奇怪,在MigrateFeatureStates標準動作應該採取的這種關心,除非你的UI重新設置狀態返回到「默認」值。我建議做兩次升級,一次使用UI(msiexec/i install.msi/l * v UILog.txt),一次安靜地升級(msiexec/i install.msi/qn/l * v quietLog.txt)並查看與特徵狀態一起發生。 –

+0

您可以使用(!FeatureID = 3)檢測是否安裝了功能。 查看鏈接瞭解更多信息: https://www.firegiant.com/wix/tutorial/com-expression-syntax-miscellanea/expression-syntax/ –

回答

相關問題