簡體   English   中英

如何在應用程序卸載時刪除有條件安裝的功能?

[英]How to remove conditionally installed features on application uninstall?

我正在使用 wix 構建一個安裝程序,該安裝程序根據從命令行傳入的“CURRENCY”屬性安裝不同的功能。

msiexec /i install.msi CURRENCY="GBP"

這是 wix 文件的特征元素:

<Feature Id="Complete" Level="1" Title="My Service" Display="expand" InstallDefault="local">
  <Feature Id="MainProgram" Title="My Service" Display="expand" Level="1" Absent="allow">
    <ComponentRef Id="MyCoordinator" />

    <Feature Id="Foo" Title="Foo" Display="expand" InstallDefault="followParent" Level="1" Absent="disallow">

      <Feature Id="UK" Title="UK Settings" Description="UK Plugin." Level="0" InstallDefault="followParent" Absent="disallow">
        <Condition Level="1">CURRENCY = "GBP"</Condition>   <<-- CONDITION
        <ComponentRef Id="UK_Settings_Component" />
      </Feature>

      <Feature Id="US" Title="US Settings" Description="US Plugin." Level="0" InstallDefault="followParent" Absent="disallow">
        <Condition Level="1">CURRENCY = "USD"</Condition>   <<-- CONDITION
        <ComponentRef Id="US_Settings_Component" />
      </Feature>

    </Feature>

  </Feature>
</Feature>

安裝過程效果很好。 我傳入一種貨幣並安裝了相應國家/地區的設置組件。

但是當我嘗試通過“添加或刪除程序”小程序卸載應用程序時,它需要用戶卸載應用程序兩次,然后才能將其從已安裝程序列表中刪除。 因此,我使用詳細日志記錄從命令行運行卸載。

> msiexec /x {product-guid} /L*v "uninstall_1.txt"
> msiexec /x {product-guid} /L*v "uninstall_2.txt"

在挖掘了詳細的卸載日志后,我相信這是因為安裝程序未能刪除特定於貨幣的設置組件。

第二次卸載后的卸載日志中,我可以看到它找到了:

Component: UK_Settings_Component; Installed: Local;   Request: Null;   Action: Local

如果我將貨幣傳遞給卸載命令,它只需要一次卸載

> msiexec /x {product-guid} CURRENCY="GBP"

問題:如何告訴它在卸載應用程序時始終刪除所有貨幣組件?

確保功能始終處於啟用狀態,以便可以將其刪除:

不過,解決方案很簡單:在啟用該功能的條件中添加OR REMOVE 這可確保在整個產品卸載或嘗試刪除該特定功能期間啟用該功能。

暫無
暫無

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

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