如何在应用程序卸载时删除有条件安装的功能?
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"
问题:如何让它在卸载应用程序时始终删除所有货币组件?
Make sure features are always enabled so they can be removed:
The solution is easy, though: Add OR REMOVE
to the condition that enables the feature. That ensures the feature is enabled during whole-product uninstall or an attempt to remove that particular feature.
我正在使用 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"
问题:如何让它在卸载应用程序时始终删除所有货币组件?
Make sure features are always enabled so they can be removed:
The solution is easy, though: Add
OR REMOVE
to the condition that enables the feature. That ensures the feature is enabled during whole-product uninstall or an attempt to remove that particular feature.