如何使用 MajorUpgrade 和 RemoveFeatures 仅删除特定功能并仍然卸载产品的先前版本

2024-03-24

我从与 VS 2010 一起打包的 Microsoft 安装程序切换到 Wix 3.6。我试图通过使用<MajorUpgrade/>标记,但是我不想在执行此重大升级时卸载一项功能。

如下所示我有RemoveFeatures="[ProductFeature]"这将导致仅删除 ProductFeature,而保留 DataFeature,但这会导致该条目不会从 Windows 的“程序和功能”列表中删除,就像未指定此参数时一样。如何在不卸载特定功能的情况下正确升级?

<Product Id="*" 
       Name="$(var.MyProject.ProjectName)" 
       Language="1033" 
       Version="2.6.0.0" 
       Manufacturer="Awesome Software (Pty) Ltd"          
       UpgradeCode="D7B99D7F-340D-449D-9C18-5D4A4A9B13D5">       
<Package InstallerVersion="405"
         Compressed="yes"              
         Description="Installs $(var.MyProject.ProjectName)"             
     Keywords="Awesome"
     InstallScope="perMachine"/>

<WixVariable Id="WixUILicenseRtf" Value="$(var.SolutionDir)\awesome.EULA\awesome CE Eula.rtf" />
<MediaTemplate EmbedCab="yes"/>
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." 
RemoveFeatures="[ProductFeature]" Schedule="afterInstallInitialize"/>

<Feature Id="ProductFeature" Title="Setup $(var.MyProject.ProjectName)" Level="1">      
  <ComponentGroupRef Id="FilesFragment" />
  <ComponentRef Id="C__5B1F76E18B8F479DAAA1B8C14E4B0638"/>
  <ComponentRef Id="C__5B1F76E18B8F479DAAA1B8C14E4B0639"/>
  <ComponentRef Id="cmpA0688C6933D519CB5D1B6D48D50F1E21"/>
</Feature>

<Feature Id="DataFeature" Title="Data $(var.MyProject.ProjectName)" Level="1" >
  <ComponentGroupRef Id="DataFragment" />
</Feature>

<!-- Wix UI Prompts -->
<Property Id="WIXUI_INSTALLDIR" Value="APPLICATIONFOLDER"/>            
<UIRef Id="WixUI_InstallDir"/>

<Binary Id="myCustomActionsDLL" SourceFile="$(var.CustomActions.TargetDir)MaxCut.CustomActions.CA.dll"/>

<InstallExecuteSequence>
  <Custom Action="CA_myCustomAction" Before="InstallInitialize"/>
</InstallExecuteSequence>

如果您不卸载所有功能,Windows Installer 会将旧产品保留在计算机上。这通常发生在以下情况:Condition在一个Feature卸载期间评估为 false。您已经找到了另一种方法来实现该场景。每次发生这种情况都会让人们感到困惑。

简短的回答:您无法使用功能完成您想要做的事情。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何使用 MajorUpgrade 和 RemoveFeatures 仅删除特定功能并仍然卸载产品的先前版本 的相关文章

随机推荐