我已经尝试了10个小时,但我没有得到它的工作。下面是我的代码(摘录):
<Fragment>
<util:RegistrySearch Id="VC_REDIST_Version"
Root="HKCR"
Variable="VCREDIST143431931"
Key="InstallerDependenciesVC,redist.x86,x86,14.34,bundle"
Format="raw"
Value="Version"
Result="value" />
<ComponentGroup Id="ThirdPartyComponents" Directory="ExtSources">
<Component Id="Component_VC_redist_x86" Guid="2B80F89A-990A-438E-A475-9E72d8A0198A" >
<File Id="ExtSources_VC_redist.x86.exe" Name="VC_redist.x86.exe" Source="$(var.xxxxx_TargetDir)ExtSourcesVC_redist.x86.exe" />
</Component>
</ComponentGroup>
<CustomAction Id="Install_VC_redist_x86"
Execute="immediate"
Impersonate="no"
Return="asyncNoWait"
FileKey="ExtSources_VC_redist.x86.exe"
ExeCommand="" />
<InstallExecuteSequence>
<Custom Action="Install_VC_redist_x86" After="InstallFinalize">NOT VCREDIST143431931</Custom>
</InstallExecuteSequence>
</Fragment>
但问题是自定义动作总是独立于状态执行的。
你知道哪里出了问题吗?
更新:
现在我是这样做的,当已经安装了一个更新或相同版本的vc发行版时,它可以跳过调用安装程序:
<Fragment>
<Property Id="VCREDISTINSTALLED">
<RegistrySearch Id="VCRedistInstalledSearch"
Root="HKCR"
Key="InstallerDependenciesVC,redist.x86,x86,14.34,bundle"
Name="Version"
Type="raw"
Win64="no"/>
</Property>
<ComponentGroup Id="ThirdPartyComponents" Directory="ExtSources">
<Component Id="Component_VC_redist_x86" Guid="2B80F89A-990A-438E-A475-9E72d8A0198A" >
<File Id="ExtSources_VC_redist.x86.exe" Name="VC_redist.x86.exe" Source="$(var.xxxxx_TargetDir)ExtSourcesVC_redist.x86.exe" />
</Component>
</ComponentGroup>
<CustomAction Id="Install_VC_redist_x86"
Execute="immediate"
Return="asyncNoWait"
FileKey="ExtSources_VC_redist.x86.exe"
ExeCommand="/quiet /norestart" />
<InstallExecuteSequence>
<Custom Action="Install_VC_redist_x86" After="InstallFinalize"><![CDATA[VCREDISTINSTALLED < "14.34.31931.0" AND NOT REMOVE]]></Custom>
</InstallExecuteSequence>
</Fragment>
您将需要使用RegistrySearch
而不是util:RegistrySearch
。util:RegistrySearch
仅在bundle中被识别。在WiX v4中,有一个错误消息,但在WiX v3中,它被静默忽略。