![](/img/trans.png)
[英]remove program from programs and features when installing newer version msi using wix
[英]When installing MSI for current user only, the old version of application is not uninstalled (appears in Add/Remove programs twice)
我有一個帶有WiX安裝程序的應用程序,該程序帶有標准的Just Me / All users選項,該選項設置ALLUSERS屬性。
當我使用“ Just Me”選項安裝,然后使用相同的“ Just Me”選項安裝該應用程序的更高版本時,它顯然不會檢測到該應用程序的舊版本,並重復了“添加/刪除程序”(和每個后續版本都會在“添加/刪除程序”中創建自己的條目)。
當我選擇“為所有用戶安裝”選項時,這永遠不會發生-在這種情況下,舊版本將被刪除。
這是InstallExecuteSequence:
<InstallExecuteSequence>
<!-- Only schedule this custom action for the 32-bit MSI. -->
<?if $(var.DependenciesPlatform)=x86 ?>
<Custom Action="CA_Err32BitMsiOn64BitOS" After="LaunchConditions">
<![CDATA[MsiAMD64 OR Intel64]]>
</Custom>
<?endif ?>
<Custom Action="PreventDowngrading" After="FindRelatedProducts">NEWPRODUCTFOUND</Custom>
<RemoveExistingProducts Sequence="1" />
<Custom Action="LaunchApp" After="InstallFinalize" />
<InstallInitialize></InstallInitialize>
<RemoveShortcuts></RemoveShortcuts>
<InstallFiles></InstallFiles>
<CreateShortcuts></CreateShortcuts>
<InstallFinalize></InstallFinalize>
<ScheduleReboot After="InstallFinalize"/>
</InstallExecuteSequence>
我也有這個升級元素:
<Upgrade Id="$(var.UpgradeCode)">
<!-- Detect any newer version of this product -->
<UpgradeVersion Minimum="$(var.Version)" IncludeMinimum="no" OnlyDetect="yes" Property="NEWPRODUCTFOUND"/>
<!-- Detect and remove any older version of this product -->
<UpgradeVersion Maximum="$(var.Version)" IncludeMaximum="yes" OnlyDetect="no" Property="OLDPRODUCTFOUND"/>
</Upgrade>
包裝和產品ID設置為????-...??
<Package Id="????????-????-????-????-????????????"
InstallerVersion="200"
Compressed="$(var.Compressed)"
InstallPrivileges="elevated"
/>
<Product Id="????????-????-????-????-????????????"
Name="$(var.ProductFullName)"
Language="$(loc.LANG)"
Codepage="1250"
Version="$(var.Version)"
Manufacturer="Company"
UpgradeCode="$(var.UpgradeCode)"
>
UpgradeCode是常量。
這是指定ALLUSERS屬性的方式:
<Publish Property="ALLUSERS" Value="{}"><![CDATA[FolderForm_AllUsers="ME" AND VersionNT>=400 AND Privileged=1 AND FolderForm_AllUsersVisible=1]]></Publish>
我使用/ i / l * vx選項運行了msiexec,但是在日志中未找到任何相關內容。
ALLUSERS屬性被刪除 -這可能是原因嗎? 我認為這是因為Publish元素,因為當我將Value更改為例如1時,它不會刪除該屬性。
MSI (c) (5C:E4) [10:15:14:807]: PROPERTY CHANGE: Deleting ALLUSERS property. Its current value is '1'.
RemoveExistingProducts已執行,但不報告任何內容:
MSI (s) (54:E4) [17:01:22:095]: Running ExecuteSequence
MSI (s) (54:E4) [17:01:22:095]: Doing action: RemoveExistingProducts
MSI (s) (54:E4) [17:01:22:095]: Note: 1: 2205 2: 3: ActionText
Action 17:01:22: RemoveExistingProducts. Removing applications
Action start 17:01:22: RemoveExistingProducts.
Action ended 17:01:22: RemoveExistingProducts. Return value 1.
為什么選擇“僅我”選項時不能刪除舊版本?
WiX 2.0.5805,很遺憾,我目前無法升級到新版本的WiX
無論如何,您可能應該發布日志,以防更多的眼睛察覺到相關的內容。 FindRelatedProducts通常是查看它是否檢測到先前版本的地方。
通常,此方法可行,並且您需要在WiX中提供諸如majorupgrade元素之類的內容以提供框架-默認情況下不會發生這種情況。 UpgradeCode必須與原始設置相同,ProductCode不同,ProductVersion的前3位遞增。
從Installshield中檢查以下KDB條目: http : //helpnet.installshield.com/installshield17helplib/IHelpISSetAllUsers.htm
Extraxt:“ ...新安裝的ALLUSERS屬性必須與已安裝版本的屬性匹配,以便FindRelatedProducts操作成功進行升級安裝。此外,如果僅為一個特定用戶安裝了以前的版本,並且針對對於所有用戶,最終的安裝已損壞,並且可能無法正確卸載。ISSetAllUsers通過重置ALLUSERS屬性消除了這些問題。
我不知道Wix中有一個等效的內置功能,但是您應該能夠進行自己的自定義操作來檢查此操作,而不必太麻煩。
進一步的調試顯示了問題的根源:FindRelatedProducts報告當前安裝是按機器安裝的。
MSI(c)(60:B8)[14:53:00:996]:FindRelatedProducts: 當前安裝是按機器安裝的 。 產品'<>'的相關安裝是按用戶安裝的。 跳繩...
僅在FindRelatedProducts之后才修改ALLUSERS屬性(來自同一安裝,請注意時間戳)。
MSI(c)(60:14)[14:53:05:885]:屬性更改:刪除ALLUSERS屬性。 當前值為“ 1”。
問題在於,ALLUSERS已在腳本中預先設置。
<Property Id="ALLUSERS" Secure="yes">1</Property>
過去有人試圖強制每台計算機安裝時,它可能保留在WiX腳本中。
刪除該行解決了該問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.