【问题标题】:Wix upgrade msi removing already installed featuresWix 升级 msi 删除已安装的功能
【发布时间】:2017-04-04 04:30:20
【问题描述】:

我正在使用 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="@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>

【问题讨论】:

  • 看起来很奇怪,除非您的 UI 将状态重新设置为“默认”值,否则 MigrateFeatureStates 标准操作应该会处理此问题。我建议进行两次升级,一次是使用 UI (msiexec /i install.msi /lv UILog.txt),一次是悄悄地 (msiexec /i install.msi /qn /lv quietLog.txt)。 txt) 并查看功能状态会发生什么。
  • 您可以使用 (!FeatureID=3) 来检测是否安装了功能。查看链接了解更多信息:firegiant.com/wix/tutorial/com-expression-syntax-miscellanea/…
  • 我遇到了与此问题中描述的相同的问题。 @AshishKamat 关于表达式的评论似乎指向了正确的方向,但我还无法基于此创建一个可行的解决方案。有人可以提供一个工作示例吗?我会加个赏金...

标签: wix wix3


【解决方案1】:

@dpb 的回答可以解决问题,因为MajorUpgrade 标记有一个MigrateFeatures 属性,其隐式默认值为yes。 但是,仅当您确实想为您的产品创建 major update 时才相关,这会产生影响。 - 这不是我的选择。

如果您不想执行重大更新,则必须将MigrateFeatures 属性添加到UpgradeVersion 标记并将其值明确设置为yes


InstallExecuteSequence 标签下方的MigrateFeatureStates action 只是次要的。

如上所述,如果没有MigrateFeatures="yes" 属性(隐式或显式),则此操作将执行。

如果有MigrateFeatures="yes" 属性,MigrateFeatureStates 操作将自动添加到安装程序的 InstallExecuteSequence 表中。

如果要调整动作在执行顺序中的位置,只需在InstallExecuteSequence标签中显式定义MigrateFeatureStates动作即可。

【讨论】:

    【解决方案2】:

    尝试使用MajorUpgrade 标签。

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

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

    【讨论】:

    • 我看不出这个答案应该如何解决问题。
    • 这个答案并没有我最初想的那么糟糕。它会在某些情况下解决问题。但是,这个答案和链接的线程都没有解释为什么这会有所帮助。
    猜你喜欢
    • 1970-01-01
    • 2017-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-21
    相关资源
    最近更新 更多