我们有一个用 Wix 创建的产品安装程序,其中包含一个程序包(“V1”)和一些配置文件。现在,我们将使用新的产品代码进行重大升级,其中旧版本的产品被卸载并且“V2“已安装。我们想要的是保存其中一个配置文件以防止卸载,因为 V2 也需要它。不幸的是,我们忘记设置Permanent="yes"
当我们交付 V1 时的选项(阅读这个问题 https://stackoverflow.com/questions/2631063/wix-leave-files-after-uninstall了解更多信息)。
问题来了:有没有一种简单的方法可以防止文件被卸载无论如何?当然,我们可以在脚本中添加一个自定义操作来在卸载之前备份文件,并在卸载之后添加另一个自定义操作来恢复它,但恕我直言,这对于此任务来说似乎有些过分,并且可能会干扰 MSI 注册过程的其他部分。
编辑:是的,NeverOverwrite="yes"
属性已在 V2 中设置,并且行为如我所描述。
我认为直接更改 V2 的组件参数不会有帮助。也许在卸载 V1 之前有机会在自定义操作中以某种方式修改注册表,因此安装程序服务认为 V1 中的配置文件是通过以下方式安装的:Permanent="yes"
?
Try the NeverOverwrite
配置文件的属性
如果该属性设置为“yes”,则
安装程序无法安装或
如果有关键路径,请重新安装组件
文件或关键路径注册表项
该组件已经存在。
EDIT
我刚刚在测试设置中对此进行了测试。起初它不起作用,因为我已经安排了RemoveExistingProducts
之前的行动InstallInitialize
顺序。这会在安装新产品之前删除旧产品,因此无法进行比较。
但是当我将其设置为之后InstallFinalize
它确实有效,即使原始设置没有,它仍将文件留在那里NeverOverwrite
放。这是我的两个测试示例
版本1.0.0.0
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="35d07bf8-a729-402d-83d6-fdc55799a3d5" Language="1033" Manufacturer="..." Name="test1" UpgradeCode="9773a278-068d-4fac-8241-4a5b7e54f15a" Version="1.0.0.0">
<Package Compressed="no" InstallerVersion="200" />
<Property Id="ALLUSERS" Value="1" />
<Upgrade Id="9773a278-068d-4fac-8241-4a5b7e54f15a">
<UpgradeVersion OnlyDetect="no" Property="REMOVEOLDVERSION" Maximum="1.0.0.0" IncludeMaximum="no" />
<UpgradeVersion OnlyDetect="yes" Property="NEWERFOUND" Minimum="1.0.0.0" IncludeMinimum="no" />
</Upgrade>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder" Name="ProgramFilesFolder">
<Directory Id="INSTALLDIR" Name="test1">
<Component Id="New_Text_Document.txt" Guid="{CCA38D83-A890-4528-B11D-DA2E2DCDED93}" Feature="ProductFeature">
<File Id="New_Text_Document.txt" KeyPath="yes" Source="Harvest\ProgramFilesFolder\INSTALLDIR\New Text Document.txt" />
</Component>
</Directory>
</Directory>
</Directory>
<Feature Id="ProductFeature" Level="1" Title="CompletePackage" Description="The complete Product." Display="expand" />
<CustomAction Id="NewerFound" Error="A later version of [ProductName] is already installed" />
<InstallExecuteSequence>
<Custom Action="NewerFound" After="FindRelatedProducts">NEWERFOUND</Custom>
<RemoveExistingProducts After="InstallFinalize" />
</InstallExecuteSequence>
<UIRef Id="WixUI_Minimal" />
<Media Id="1" />
<UI />
</Product>
</Wix>
版本1.0.1.0
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="1da36626-d760-4c4c-8a5c-3eb3841dbfd5" Language="1033" Manufacturer="..." Name="test1" UpgradeCode="9773a278-068d-4fac-8241-4a5b7e54f15a" Version="1.0.1.0">
<Package Compressed="no" InstallerVersion="200" />
<Property Id="ALLUSERS" Value="1" />
<Upgrade Id="9773a278-068d-4fac-8241-4a5b7e54f15a">
<UpgradeVersion OnlyDetect="no" Property="REMOVEOLDVERSION" Maximum="1.0.1.0" IncludeMaximum="no" />
<UpgradeVersion OnlyDetect="yes" Property="NEWERFOUND" Minimum="1.0.1.0" IncludeMinimum="no" />
</Upgrade>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder" Name="ProgramFilesFolder">
<Directory Id="INSTALLDIR" Name="test1">
<Component Id="New_Text_Document.txt" Guid="{CCA38D83-A890-4528-B11D-DA2E2DCDED93}" Feature="ProductFeature" NeverOverwrite="yes">
<File Id="New_Text_Document.txt" KeyPath="yes" Source="Harvest\ProgramFilesFolder\INSTALLDIR\New Text Document.txt" />
</Component>
</Directory>
</Directory>
</Directory>
<Feature Id="ProductFeature" Level="1" Title="CompletePackage" Description="The complete Product." Display="expand" />
<CustomAction Id="NewerFound" Error="A later version of [ProductName] is already installed" />
<InstallExecuteSequence>
<Custom Action="NewerFound" After="FindRelatedProducts">
NEWERFOUND</Custom>
<RemoveExistingProducts After="InstallFinalize" />
</InstallExecuteSequence>
<UIRef Id="WixUI_Minimal" />
<Media Id="1" />
<UI />
</Product>
</Wix>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)