MajorUpgrade元素计划在我们产品的MSI:中安装完成后进行
<MajorUpgrade Schedule="afterInstallFinalize" AllowSameVersionUpgrades="yes" DowngradeErrorMessage="!(loc.NewerVersionInstalled)" IgnoreRemoveFailure="no"/>
有一些由应用程序在运行时编写的文件夹,我们希望在升级时保留,并且仅在从"添加/删除"程序启动卸载时删除。所以我们使用这个条件:(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")
。
<DirectoryRef Id="TARGETDIR">
...
<Directory Id="LocalAppDataFolder"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Component Id="CreatePrivateMyAppFolder" Guid="FA1F4375-71DA-4E61-9A02-BE7FD2D4C87D">
<RegistryValue Root="HKCU" Key="SoftwareCompanyProduct" Name="PrivateFolderMyApp" Type="string" Value="[PrivateDataMyApp]" KeyPath="yes"/>
</Component>
<Component Id="RemoveLocalAppDataMyAppUninstall" Guid="*" Transitive="yes">
<Condition><![CDATA[(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")]]></Condition>
<RegistryValue Root="HKCU" Key="SoftwareCompanyProduct" Name="PrivateFolderMyApp" Type="string" Value="[PrivateDataMyApp]" KeyPath="yes"/>
<util:RemoveFolderEx On="uninstall" Property="PRIVATEMYAPPFOLDER"/>
</Component>
<Directory></Directory>
...
</Directory>
</DirectoryRef>
对于一些新的需求,我需要将MajorUpgrade
计划从安装完成后的更改为安装初始化后的。我用新的时间表安装版本1。然后安装版本2。但是,在版本2的卸载过程中,运行时编写的文件夹将被删除。
从日志中,为卸载部分设置了UPGRADINGPRODUCTCODE
和REMOVE
属性。基于此,条件CCD_ 5对于分量CCD_。
MSI (s) (C4:58) [22:58:11:060]: Doing action: RemoveExistingProducts
Action 22:58:11: RemoveExistingProducts. Removing applications
Action start 22:58:11: RemoveExistingProducts.
RemoveExistingProducts: Application: {8F890AE0-BE0A-5ED9-B406-F7459B3390F9}, Command line: UPGRADINGPRODUCTCODE={70705091-36C8-5619-9E35-73E455CA17F7} CLIENTPROCESSID=4756 CLIENTUILEVEL=0 REMOVE=ALL
....
MSI (s) (C4:4C) [22:58:11:076]: Command Line: UPGRADINGPRODUCTCODE={70705091-36C8-5619-9E35-73E455CA17F7} CLIENTPROCESSID=4756 CLIENTUILEVEL=0 REMOVE=ALL
MSI (s) (C4:4C) [22:58:11:279]: Dir (target): Key: _PRIVATEMYAPPFOLDER_4 , Object: C:UsersWindows_10AppDataLocalMyApp
MSI (s) (C4:4C) [22:58:11:279]: Dir (target): Key: _PRIVATEMYAPPFOLDER_3 , Object: C:UsersWindows_10AppDataLocalMyApp1753de9b-15a7-49b1-8715-f93a967d12e5
...
MSI (s) (C4:4C) [22:58:11:826]: Doing action: InstallValidate
MSI (s) (C4:4C) [22:58:11:826]: Component: RemoveLocalAppDataMyAppUninstall; Installed: Local; Request: Absent; Action: Absent
...
MSI (s) (C4:4C) [22:58:12:732]: Doing action: RemoveFiles
MSI (s) (C4:4C) [22:58:12:919]: Counted 6 foreign folders to be removed.
MSI (s) (C4:4C) [22:58:12:919]: Removing foreign folder: C:UsersWindows_10AppDataLocalMyApp1753de9b-15a7-49b1-8715-f93a967d12e5
MSI (s) (C4:4C) [22:58:12:919]: Removing foreign folder: C:UsersWindows_10AppDataLocalMyApp
如果您能理解为什么在卸载过程中应用该条件,我们将不胜感激。
组件条件只影响安装,并在设置了可传递位的情况下影响重新安装。卸载不受影响。WiX v4中的RemoveFolderEx
有一个Condition
,可以让你做你想做的事。