Web download of vcruntime140 with wix burn

2019-03-04 14:59发布

I want to use the WiX bootstrapper burn to automatically download and install the vcruntime140 package (Visual C++ Redistributable for Visual Studio 2015) if it is required.

It's trivially easy to do this for the .NET frameworks:

<Chain>
  <PackageGroupRef Id="NetFx452Web"/>
  ...
</Chain>

but I can't find an equivalent for the vcruntime packages. (Is that because there isn't one, or am I just typing the wrong keywords into Google?)

Just to be clear: I do not want to include the package with my installer. It must be a web download.

标签: wix burn
2条回答
贼婆χ
2楼-- · 2019-03-04 15:35

Just for the record, here's my final solution.

Right-click on the bootstrapper project References in Visual Studio and add a reference to WixUtilExtension.

Add xmlns:util="http://schemas.microsoft.com/wix/UtilExtension" as an attribute to the top level Wix element.

Add to the <Chain> element:

<PackageGroupRef Id="vcredist_vc140"/>

Add as a child of the <Wix> element:

<Fragment>
  <!-- vcredist 2015 x86 -->
  <util:ProductSearch
      Id="VCREDIST_140_x86"
      UpgradeCode="65E5BD06-6392-3027-8C26-853107D3CF1A"
      Result="version"
      Variable="VCREDIST_140_x86"/>
  <PackageGroup Id="vcredist_vc140">
    <ExePackage
        Id="vc140"
        Cache="yes"
        PerMachine="yes"
        Permanent="yes"
        Vital="yes"
        Compressed="no"
        DownloadUrl="http://go.microsoft.com/fwlink/?LinkID=615459"
        Name="vcredist_vc140"
        InstallCommand="/quiet /norestart"
        DetectCondition="(VCREIST_140_x86 &gt;= v14.0.24215)">
      <RemotePayload
          Description="Microsoft Visual C++ 2015 Redistributable (x86) - 14.0.24215"
          ProductName="Microsoft Visual C++ 2015 Redistributable (x86) - 14.0.24215"
          Size="14456872"
          Version="14.0.24215.1"
          Hash="72211BD2E7DFC91EA7C8FAC549C49C0543BA791B" />
    </ExePackage>
  </PackageGroup>
</Fragment>

UpgradeCode came from this answer and is specific to v14.0.24215 of the vcredist installer. This is how the bootstrapper decides whether it is already installed.

Compressed="no" tells the installer not to include the file in the installer itself (since we want to download it from the web).

DownloadUrl is a direct URL to the downloadable installer from this answer.

RemotePayload Description is the text of the installer's Description resource and likewise ProductName. (It appears that the text does not have to match the text in the resources. ProductName is the description shown in the bootstrapper's progress dialog.)

Size is the size in bytes. Hash is found with the Powershell command get-filehash -algorithm SHA1 .\vc_redist.x86.exe.

I hope this helps someone.

查看更多
姐就是有狂的资本
3楼-- · 2019-03-04 15:39

There is no PackageGroupRef for the redist as for .net.

But there is 3 other options:

  1. Add a redist exe in your chain. (Not good for you)
  2. Use a redist c++ merge module inside one of your msi's.
  3. Try to write your own web download as .net does. Here is a sample of the .net web download. The full file can be found in the source code of wix by the name "NetFx46.wxs"
<Fragment>
 <PropertyRef Id="WIXNETFX4RELEASEINSTALLED" />
 <Property Id="WIX_IS_NETFRAMEWORK_46_OR_LATER_INSTALLED" Secure="yes" />
 <SetProperty Id="WIX_IS_NETFRAMEWORK_46_OR_LATER_INSTALLED" Value="1" After="AppSearch">
   WIXNETFX4RELEASEINSTALLED >= "#$(var.NetFx46MinRelease)"
 </SetProperty>
</Fragment>

<Fragment>
<util:RegistrySearchRef Id="NETFRAMEWORK45"/>
<WixVariable Id="WixMbaPrereqPackageId" Value="NetFx46Web" />
<WixVariable Id="WixMbaPrereqLicenseUrl" Value="http://go.microsoft.com/fwlink/?LinkID=558772" />
<WixVariable Id="NetFx46WebDetectCondition" Value="NETFRAMEWORK45 &gt;= $(var.NetFx46MinRelease)" Overridable="yes" />
<WixVariable Id="NetFx46WebInstallCondition" Value="" Overridable="yes" />
<WixVariable Id="NetFx46WebPackageDirectory" Value="redist\" Overridable="yes" />

<PackageGroup Id="NetFx46Web">
  <ExePackage
      InstallCommand="/q /norestart /ChainingPackage &quot;[WixBundleName]&quot; /log &quot;[NetFx46FullLog].html&quot;"
      RepairCommand="/q /norestart /repair /ChainingPackage &quot;[WixBundleName]&quot; /log &quot;[NetFx46FullLog].html&quot;"
      UninstallCommand="/uninstall /q /norestart /ChainingPackage &quot;[WixBundleName]&quot; /log &quot;[NetFx46FullLog].html&quot;"
      PerMachine="yes"
      DetectCondition="!(wix.NetFx46WebDetectCondition)"
      InstallCondition="!(wix.NetFx46WebInstallCondition)"
      Id="NetFx46Web"
      Vital="yes"
      Permanent="yes"
      Protocol="netfx4"
      DownloadUrl="http://go.microsoft.com/fwlink/?LinkId=560371"
      LogPathVariable="NetFx46FullLog"
      Compressed="no"
      Name="!(wix.NetFx46WebPackageDirectory)NDP46-KB3045557-x86-x64-AllOS-ENU.exe">
    <RemotePayload 
      CertificatePublicKey="52868DFCA6E3AF2632389E6C1EE7D0468D3797D0" 
      CertificateThumbprint="3BDA323E552DB1FDE5F4FBEE75D6D5B2B187EEDC" 
      Description="Microsoft .NET Framework 4.6 Setup" 
      Hash="480CA134B9E3F2437DF10719D5A8C77DDEC0A4F1" 
      ProductName="Microsoft .NET Framework 4.6" 
      Size="1497400" 
      Version="4.6.81.0" />
  </ExePackage>
</PackageGroup>

查看更多
登录 后发表回答