检测vcredist的存在 - 使用UpgradeCode

时间:2016-03-08 16:12:54

标签: wix windows-installer burn vcredist

wix刻录引导程序包中:如何检测ms vcredist 2013 x86是否存在?
我正在检查该特定软件包的Upgrade Id / UpgradeCode,但软件包总是重新安装它,即使它已经安装了。

...
<Bundle>
    ...
    <Chain>
        <!-- redist packages -->
        <PackageGroupRef Id="redist"/>
        ...
    </Chain>
</Bundle>

<Fragment>
    <PackageGroup Id="redist">
        <PackageGroupRef Id="redist_vc120" />
        ...
    </PackageGroup>
</Fragment>

<Fragment>
    <!-- vcredist 2013 x86 -->
    <?define vcredist2013minversion="12.0.21005"?>
    <Upgrade Id="B59F5BF1-67C8-3802-8E59-2CE551A39FC5">
        <UpgradeVersion Minimum="$(var.vcredist2013minversion)" Property="VCREDIST2013INSTALLED" OnlyDetect="yes" IncludeMinimum="yes" />
    </Upgrade>

    <PackageGroup Id="redist_vc120">
        <ExePackage Id="vc120" Cache="yes" PerMachine="yes" Permanent="yes" Vital="yes" Compressed="yes"
            Name="redist\VC120_Runtime\vcredist_x86.exe"
            InstallCommand="/quiet /norestart"
            InstallCondition="Not VCREDIST2013INSTALLED"
        />
    </PackageGroup>
</Fragment>
...

InstallCondition是否有问题? 还是我需要添加DetectCondition

在日志文件中显示:

Detected related package: {13A4EE12-23EA-3371-91EE-EFB36DDFFF3E}, scope: PerMachine, version: 12.0.21005.0, language: 0 operation: MajorUpgrade
Detected package: vc120, state: Absent, cached: None
Condition 'Not VCREDIST2013INSTALLED' evaluates to true.
Planned package: vc120, state: Absent, default requested: Present, ba requested: Present, execute: Install, rollback: None, cache: Yes, uncache: No, dependency: None
Applying execute package: vc120, action: Install, path: <path and command line>...
Applied execute package: vc120, result: 0x0, restart: None

但删除InstallCondition并将其替换为以下DetectCondition也不起作用:

<PackageGroup Id="redist_vc120">
    <ExePackage Id="vc120" Cache="yes" PerMachine="yes" Permanent="yes" Vital="yes" Compressed="yes"
        Name="redist\VC120_Runtime\vcredist_x86.exe"
        InstallCommand="/quiet /norestart"
        DetectCondition="VCREDIST2013INSTALLED"
    />
</PackageGroup>

-

编辑:
只是为了进一步解释:我正在尝试UpgradeCode的方法,因为我不想检查特定的安装包,而是minimum version

2 个答案:

答案 0 :(得分:8)

以下逻辑适用于引导程序包(刻录):

<Fragment>
    <!-- vcredist 2013 x86 -->
    <util:ProductSearch Id="VCREDIST_120_x86"
        UpgradeCode="B59F5BF1-67C8-3802-8E59-2CE551A39FC5"
        Result="version"
        Variable="VCREDIST_120_x86" />

    <PackageGroup Id="redist_vc120">
        <ExePackage Id="vc120" Cache="yes" PerMachine="yes" Permanent="yes" Vital="yes" Compressed="yes"
            SourceFile="redist\VC120_Runtime\vcredist_x86.exe"
            InstallCommand="/quiet /norestart"
            DetectCondition="(VCREDIST_120_x86 &gt;= v12.0.21005)" />
    </PackageGroup>
</Fragment>

总结:

  • 对于搜索,它使用带有util:ProductSearch参数的UpgradeCode
  • 用于检测,它在DetectCondition
  • 中进行版本比较
刻录中,基于UpgradeCode的产品检测显然与 msi 不同(我们可以使用升级表和属性“OnlyDetect”,然后配置“LaunchCondition”)。

仅供参考:
我发现以下 UpgradeCodes (以及他们的最低版本)以匹配......

<强> 86

vcredist 2005 x86 - 86C9D5AA-F00C-4921-B3F2-C60AF92E2844, 8.0.61001
vcredist 2008 x86 - DE2C306F-A067-38EF-B86C-03DE4B0312F9, 9.0.30729.6161
vcredist 2010 x86 - 1F4F1D2A-D9DA-32CF-9909-48485DA06DD5, 10.0.40219
vcredist 2012 x86 - 4121ED58-4BD9-3E7B-A8B5-9F8BAAE045B7, 11.0.61030
vcredist 2013 x86 - B59F5BF1-67C8-3802-8E59-2CE551A39FC5, 12.0.40660
vcredist 2015 x86 - 65E5BD06-6392-3027-8C26-853107D3CF1A, 14.0.23506
vcredist 2017 x86 - 65E5BD06-6392-3027-8C26-853107D3CF1A, 14.15.26706
vcredist 2019 x86 - 65E5BD06-6392-3027-8C26-853107D3CF1A, 14.20.27508

<强> 64

vcredist 2005 x64 - A8D19029-8E5C-4E22-8011-48070F9E796E, 8.0.61000
vcredist 2008 x64 - FDA45DDF-8E17-336F-A3ED-356B7B7C688A, 9.0.30729.6161
vcredist 2010 x64 - 5B75F761-BAC8-33BC-A381-464DDDD813A3, 10.0.40219
vcredist 2012 x64 - EFA6AFA1-738E-3E00-8101-FD03B86B29D1, 11.0.61030
vcredist 2013 x64 - 20400CF0-DE7C-327E-9AE4-F0F38D9085F8, 12.0.40660
vcredist 2015 x64 - 36F68A90-239C-34DF-B58C-64B30153CE35, 14.0.23506
vcredist 2017 x64 - 36F68A90-239C-34DF-B58C-64B30153CE35, 14.15.26706
vcredist 2019 x64 - 36F68A90-239C-34DF-B58C-64B30153CE35, 14.20.27508

编辑历史记录:

1)根据Brian Sutherland的评论更新了vcredist 2017 x86的UpradeCode。 VS 2015,VS 2017和VS 2019都属于14.*的同一系列。

2)添加x64变体来回答艾哈迈德丹尼尔评论中的问题。更新的列表主要是通过运行解决方案的修改版本来确定的,如答案https://stackoverflow.com/a/46637095中所示 遗憾的是,微软没有关于这些特定升级代码的官方文档,但我们只需要去弄清楚自己...

答案 1 :(得分:-1)

我使用注册表搜索来检查是否安装,尝试将其作为:

<util:RegistrySearch
  Root="HKLM"
  Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\<Place Guid>"
  Value="DisplayVersion"
  Variable="MSVC_2013_x64"
  Win64="yes"/>

,条件为:

DetectCondition="MSVC_2013_x64 AND (MSVC_2013_x64 &gt;= v12.0.21005)"