1

我正在按照每个用户安装程序的 Wix 示例来检测 Visual C++ 2015 Redistributable以检测每个用户安装程序中的 VC+ 2015-2019 可再发行组件,但没有任何运气。我已经检查了 VC++ 2017-19 是否正确安装在我的系统上,如果我进行如下简单测试,它确实可以工作。

<Property Id="CPPRUNTIME2015X86">
    <RegistrySearch Id="mfc1429x86" Root="HKCR" Key="Installer\Dependencies\VC,redist.x86,x86,14.29,bundle" Type="raw" />
</Property>
<Condition Message="Microsoft Visual C++ 2015-2019 (x86) Redistributable missing">
    <![CDATA[Installed OR CPPRUNTIME2015X86]]>
</Condition>

但是,以下通用解决方案在我的系统上找不到可分发的内容。知道为什么吗?

    <Property Id="CPPRUNTIME2015X86" Secure="yes">
        <!-- C++ 2015 -->
        <RegistrySearch Id="mfc140x86_23026" Root="HKLM" Key="SOFTWARE\Classes\Installer\Dependencies\{74d0e5db-b326-4dae-a6b2-445b9de1836e}" Type="raw" />
        <RegistrySearch Id="mfc140x86_24215" Root="HKLM" Key="SOFTWARE\Classes\Installer\Dependencies\{e2803110-78b3-4664-a479-3611a381656a}" Type="raw" />

        <!-- C++ 2017 -->
        <RegistrySearch Id="mfc1416x86" Root="HKCR" Key="Installer\Dependencies\VC,redist.x86,x86,14.16,bundle" Type="raw" />

        <!-- C++ 2019 -->
        <?foreach CPPRUNTIMEVERSIONPREFIX in 21;22;23;24;25;26;27;28;29;30;31;32;33;34;35;36;37;38;39;40?>
            <RegistrySearch Id="mfc14$(var.CPPRUNTIMEVERSIONPREFIX)x86" Root="HKCR" Key="Installer\Dependencies\VC,redist.x86,x86,14.$(var.CPPRUNTIMEVERSIONPREFIX),bundle" Type="raw" />
        <?endforeach ?>
    </Property>
    <Condition Message="Microsoft Visual C++ 2015-2019 (x86) Redistributable missing">
        <![CDATA[((REMOVE="ALL")) OR Installed]]>
    </Condition>
4

1 回答 1

1

在您的工作代码中,您搜索注册表项并将结果存储在 CPPRUNTIME2015X86 中。然后您的条件测试 CPPRUNTIME2015X86:

<Condition Message="Microsoft Visual C++ 2015-2019 (x86) Redistributable missing">
<![CDATA[Installed OR CPPRUNTIME2015X86]]>

在非工作代码中搜索注册表项并将结果存储在 CPPRUNTIME2015X86 中。但是这次您的 Condition 没有测试 CPPRUNTIME2015X86:

   <Condition Message="Microsoft Visual C++ 2015-2019 (x86) Redistributable missing">
    <![CDATA[((REMOVE="ALL")) OR Installed]]>
</Condition>

这告诉我你检查注册表没问题,但你不使用这些信息。

如果您使用工作代码中的 Condition 测试,那么它是否有效?

于 2021-07-10T19:43:16.157 回答