簡體   English   中英

Wix 升級 msi 刪除已安裝的功能

[英]Wix upgrade msi removing already installed features

我正在使用 Wix 工具集為我的應用程序生成 an.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="@product.name@" Version="@product.version@" Manufacturer="@product.company@" Language="1033">
            <Package InstallerVersion="400" Compressed="yes" InstallScope="perMachine" Comments="@product.version@" Description="@product.description@"/>
            <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="@product.version@" OnlyDetect="yes" Property="NEWERVERSIONDETECTED"/>
                <UpgradeVersion Minimum="0.0.0" Maximum="@product.version@" 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">
                        @product.applicationcomponents@
                        <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">
                        @product.servicecomponents@    
                        <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="@product.sourcedir@\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>

@dpb 的回答可以解決問題,因為MajorUpgrade標記有一個MigrateFeatures屬性,其隱式默認值為yes 但是,只有當您確實想要對您的產品進行重大更新時,它才有意義,這會產生影響。 - 這不是我的選擇。

如果您不想執行重大更新,則必須將MigrateFeatures屬性添加到UpgradeVersion標記並將其值明確設置為yes


InstallExecuteSequence標記下方的MigrateFeatureStates操作僅次要。

如果沒有MigrateFeatures="yes"屬性(隱式或顯式),則不會執行此操作,如上所述。

如果有MigrateFeatures="yes"屬性, MigrateFeatureStates操作將自動添加到安裝程序的 InstallExecuteSequence 表中。

如果要調整執行順序中的操作的 position,您只需要在InstallExecuteSequence標記中顯式定義MigrateFeatureStates操作。

嘗試使用MajorUpgrade標記。

`<MajorUpgrade DowngradeErrorMessage="Can’t downgrade." />`

https://stackoverflow.com/a/11028847/7165196

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM