我创建了一个带有“Hello world”自定义操作的简单 WIX 项目,并检查了它是如何工作的。我打算只在第一次安装时执行自定义操作,但它会在每次重大更新时执行(产品代码及其版本都发生变化)。我在日志中发现卸载后检查了自定义操作条件 - 当Installed
变量再次为 false 时。
如何使用 WIX 工具集仅在首次安装时而不是在重大更新时执行自定义操作?有没有办法不手动使用注册表?
<Product Id="52D5F5ED0C3F453CA70E280ECD7D7400"
Name="TestWiXSetup"
Language="1033"
Version="1.0.2.0"
Manufacturer="Some RnD"
UpgradeCode="12777105-8bc1-47b5-8b36-2705ef02cb79">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab='yes' />
<Feature Id="ProductFeature" Title="TestWiXSetup" Level="1">
<ComponentRef Id="Component" />
</Feature>
<Binary Id="HW" SourceFile="HW.exe" />
<CustomAction Id="HWA" BinaryKey="HW" ExeCommand="" Execute='deferred'/>
<InstallExecuteSequence>
<Custom Action='HWA' After='InstallFinalize'>NOT Installed</Custom>
</InstallExecuteSequence>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="TestWiXSetup">
<Component Id="Component">
<File Source="ToDeploy.txt"/>
</Component>
</Directory>
</Directory>
</Directory>
</Fragment>