在WiX捆绑层级:如何判断要执行安装还是卸载?
我想在捆绑层级上判断用户想要执行的操作是安装还是卸载。这是因为我的代码中还包含一个必须确保产品未被安装的 'Condition'。然而,'Uninstall'-操作必须始终能够进行。我也知道在这个层级上内置变量 'WixBundleAction' 不可用,但其实这正是我需要的(我想)。
有人知道怎么实现吗?
请看下方代码:
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal"
xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
<Bundle UpgradeCode="{94447A2A-6CB4-42DE-942A-1500531F05A9}"
Name="Motor UI Software"
Manufacturer="Remuld B.V."
Version="$(var.BuildVersion)"
DisableModify="yes">
<!-- Search for installation of TC.MotorUi.Files.msi (search for UpgradeCode) -->
<util:ProductSearch UpgradeCode="{3B46D4C3-1EA9-63F2-A8FF-3DA48692CA43}"
Result="state"
Variable="EXISTING_FILES_STATE" />
<!-- Only continue if productState is absent (2) OR during Uninstall, else exit with message. -->
<bal:Condition Message="An existing installation was detected, setup cannot continue. Please uninstall existing version first!"
Condition="EXISTING_FILES_STATE = 2 OR WixBundleAction = 3" /> <!-- WixBundleAction not available at this point -->
<BootstrapperApplication>
<bal:WixStandardBootstrapperApplication Theme="rtfRemMotr"
LicenseFile="Resources\EULA.rtf"
ThemeFile="Resources\Theme.xml"
LocalizationFile="Resources\Theme.wxl"
LogoFile="Resources\RemSideLogo.png"
SuppressOptionsUI="yes"
SuppressRepair="yes" />
</BootstrapperApplication>
<Chain>
...
...
</Chain>
</Bundle>
</Wix>
解决方案
I'd try WixBundleInstalled, I think it's set early enough for wixstdba. Something like:
<!-- Only continue if already installed OR productState is absent (2). -->
<bal:Condition Message="An existing installation was detected, setup cannot continue. Please uninstall existing version first!"
Condition="WixBundleInstalled OR EXISTING_FILES_STATE = 2" />
这在所有启动条件中都相当重要,这样用户在卸载时就不会被阻止。
站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。