简体   繁体   English

Wix 升级 msi 删除已安装的功能

[英]Wix upgrade msi removing already installed features

I am using the Wix Toolset to generate an.msi for my application.我正在使用 Wix 工具集为我的应用程序生成 an.msi。 Everything works when I upgrade to a new version, except every time I run a newer version installation the setup doesn't detect already installed features and instead defaults to the features that are 'required' which means if the user installed any of the other features they are removed unless the user explicitly checks them for installation again.当我升级到新版本时,一切正常,除了每次我运行更新版本安装时,安装程序不会检测已安装的功能,而是默认为“必需”的功能,这意味着如果用户安装了任何其他功能它们将被删除,除非用户再次明确检查它们是否安装。

Is there anyway to have the.msi detect which features are currently installed each time a newer version is installed?无论如何,每次安装新版本时,.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's answer would solve the problem, because the MajorUpgrade tag has a MigrateFeatures attribute with an implicit default value of yes . @dpb 的回答可以解决问题,因为MajorUpgrade标记有一个MigrateFeatures属性,其隐式默认值为yes However, it is only relevant if you actually want to create a major update to your product, which has implications.但是,只有当您确实想要对您的产品进行重大更新时,它才有意义,这会产生影响。 - This is not an option for me. - 这不是我的选择。

If you do not want to perform a major update, you must add the MigrateFeatures attribute to the UpgradeVersion tag and explicitly set it's value to yes .如果您不想执行重大更新,则必须将MigrateFeatures属性添加到UpgradeVersion标记并将其值明确设置为yes


The MigrateFeatureStates action below the InstallExecuteSequence tag is of minor importance only. InstallExecuteSequence标记下方的MigrateFeatureStates操作仅次要。

This action will not be executed if there is no MigrateFeatures="yes" attribute (implicit or explicit), as described above.如果没有MigrateFeatures="yes"属性(隐式或显式),则不会执行此操作,如上所述。

If there is a MigrateFeatures="yes" attribute, the MigrateFeatureStates action will automatically be added to the InstallExecuteSequence table of the installer.如果有MigrateFeatures="yes"属性, MigrateFeatureStates操作将自动添加到安装程序的 InstallExecuteSequence 表中。

You only need to explicitly define the MigrateFeatureStates action in the InstallExecuteSequence tag, if you want to adjust the action's position in the execution sequence.如果要调整执行顺序中的操作的 position,您只需要在InstallExecuteSequence标记中显式定义MigrateFeatureStates操作。

Try using MajorUpgrade tag. 尝试使用MajorUpgrade标记。

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM