简体   繁体   English

使用WIX安装程序安装.NET Framework 4.7.2(如果需要)

[英]Install .NET Framework 4.7.2 (if needed) with WIX installer

Help! 救命! I've inherited a .NET project with a WIX installer project. 我继承了一个带有WIX安装程序项目的.NET项目。 They make the implicit assumption that .NET Framework 4.5 is installed on each machine which for the most part is true. 他们隐含的假设是.NET Framework 4.5安装在每台机器上,而这些机器大部分都是正确的。 Now we are adding some features that require .NET Framework 4.7.2 . 现在我们要添加一些需要.NET Framework 4.7.2的功能。 I'd like to modify the install set to check for the presence of 4.7.2 (or higher) and install via web if necessary. 我想修改安装集以检查是否存在4.7.2(或更高版本),并在必要时通过Web安装。 I've found some documentation that's partially answered my questions but I'm still very confused how to get started and how to fill in the specifics. 我发现一些文档部分回答了我的问题,但我仍然很困惑如何开始以及如何填写细节。 Are there any complete demos or instructions available? 有没有完整的演示或说明? My understanding is that I need to add a "BootStrapper" project. 我的理解是我需要添加一个“BootStrapper”项目。 I'm confused if I then add/reference the BootStrapper project from my main install (my existing install) OR if I reference the main install as part of the Bootstrapper project (via MsiPackage element). 我很困惑,如果我然后从我的主安装(我现有的安装)添加/引用BootStrapper项目或者如果我引用主安装作为Bootstrapper项目的一部分(通过MsiPackage元素)。 Also, how do I set things up to check for 4.7.2? 另外,如何设置以检查4.7.2? All the references I found were for 4.5 or earlier and apparently the place in the registry for checking has changed: 我发现的所有引用都是4.5或更早,显然在注册表中检查的位置已经改变:

How do I detect what .NET Framework versions and service packs are installed? 如何检测安装的.NET Framework版本和Service Pack?

Assuming I refer to my main install in the Bootstrapper, how do I do this? 假设我在Bootstrapper中引用我的主要安装,我该怎么做?

These are the links I've found for those interested. 这些是我为那些感兴趣的人找到的链接。 They all hint at the answers, but don't give complete answers and/or are out of date. 他们都暗示了答案,但没有给出完整的答案和/或已经过时了。

http://wixtoolset.org/documentation/manual/v3/howtos/redistributables_and_install_checks/install_dotnet.html http://wixtoolset.org/documentation/manual/v3/howtos/redistributables_and_install_checks/install_dotnet.html

https://www.firegiant.com/wix/tutorial/net-and-net/bootstrapping/ https://www.firegiant.com/wix/tutorial/net-and-net/bootstrapping/

https://wix.ronifuchs.com/ https://wix.ronifuchs.com/

Finally, I believe I am using WIX Toolset v3.11. 最后,我相信我正在使用WIX Toolset v3.11。 This is what the folder indicates (C:\\Program Files (x86)\\WiX Toolset v3.11) 这是文件夹指示的内容(C:\\ Program Files(x86)\\ WiX Toolset v3.11)

I mention this because some of the reference material refers to Wix 4.0 (Example: http://wixtoolset.org/releases/" />) 我之所以提到这一点是因为一些参考资料是指Wix 4.0(例如:http://wixtoolset.org/releases/“/>)

Thanks! 谢谢!

A ticket was opened here last year and a workaround has been provided: 去年在这里一张票,并提供了一个解决方法:

  <?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">

  <!--
        .NET Framework installation state properties

        Official documentation can be found at the following location:

           .NET Framework 4.5/4.5.1/4.5.2/4.6/4.6.1/4.6.2/4.7/4.7.1 - http://msdn.microsoft.com/en-us/library/w0x726c2(v=vs.110).aspx
    -->

  <?define NetFx471MinRelease = 461308 ?>
  <?define NetFx471WebLink = http://go.microsoft.com/fwlink/?LinkId=852092 ?>
  <?define NetFx471RedistLink = http://go.microsoft.com/fwlink/?LinkId=852104 ?>
  <?define NetFx471EulaLink = http://referencesource.microsoft.com/license.html ?>

  <Fragment>
    <PropertyRef Id="WIXNETFX4RELEASEINSTALLED" />
    <Property Id="WIX_IS_NETFRAMEWORK_471_OR_LATER_INSTALLED" Secure="yes" />
    <SetProperty Id="WIX_IS_NETFRAMEWORK_471_OR_LATER_INSTALLED" Value="1" After="AppSearch">
      WIXNETFX4RELEASEINSTALLED >= "#$(var.NetFx471MinRelease)"
    </SetProperty>
  </Fragment>

  <Fragment>
    <util:RegistrySearchRef Id="NETFRAMEWORK45"/>

    <WixVariable Id="WixMbaPrereqPackageId" Value="NetFx471Web" />
    <WixVariable Id="WixMbaPrereqLicenseUrl" Value="$(var.NetFx471EulaLink)" Overridable="yes" />
    <WixVariable Id="NetFx471WebDetectCondition" Value="NETFRAMEWORK45 &gt;= $(var.NetFx471MinRelease)" Overridable="yes" />
    <WixVariable Id="NetFx471WebInstallCondition" Value="" Overridable="yes" />
    <WixVariable Id="NetFx471WebPackageDirectory" Value="redist\" Overridable="yes" />

    <PackageGroup Id="NetFx471Web">
      <ExePackage
          InstallCommand="/q /norestart /ChainingPackage &quot;[WixBundleName]&quot; /log &quot;[NetFx471FullLog].html&quot;"
          RepairCommand="/q /norestart /repair /ChainingPackage &quot;[WixBundleName]&quot; /log &quot;[NetFx471FullLog].html&quot;"
          UninstallCommand="/uninstall /q /norestart /ChainingPackage &quot;[WixBundleName]&quot; /log &quot;[NetFx471FullLog].html&quot;"
          PerMachine="yes"
          DetectCondition="!(wix.NetFx471WebDetectCondition)"
          InstallCondition="!(wix.NetFx471WebInstallCondition)"
          Id="NetFx471Web"
          Vital="yes"
          Permanent="yes"
          Protocol="netfx4"
          DownloadUrl="$(var.NetFx471WebLink)"
          LogPathVariable="NetFx471FullLog"
          Compressed="no"
          Name="!(wix.NetFx471WebPackageDirectory)NDP471-KB4033344-Web.exe">
        <RemotePayload
          CertificatePublicKey="2ECAEC21B884B40A7C5FB141D2CBC4CDA4930752"
          CertificateThumbprint="49D59D86505D82942A076388693F4FB7B21254EE"
          Description="Microsoft .NET Framework 4.7.1 Setup"
          Hash="C0919415622D86C3D6AB19F0F92EA938788DB847"
          ProductName="Microsoft .NET Framework 4.7.1"
          Size="1434504"
          Version="4.7.2558.0" />
      </ExePackage>
    </PackageGroup>
  </Fragment>

  <Fragment>
    <util:RegistrySearchRef Id="NETFRAMEWORK45"/>

    <WixVariable Id="WixMbaPrereqPackageId" Value="NetFx471Redist" />
    <WixVariable Id="WixMbaPrereqLicenseUrl" Value="$(var.NetFx471EulaLink)" Overridable="yes" />
    <WixVariable Id="NetFx471RedistDetectCondition" Value="NETFRAMEWORK45 &gt;= $(var.NetFx471MinRelease)" Overridable="yes" />
    <WixVariable Id="NetFx471RedistInstallCondition" Value="" Overridable="yes" />
    <WixVariable Id="NetFx471RedistPackageDirectory" Value="redist\" Overridable="yes" />

    <PackageGroup Id="NetFx471Redist">
      <ExePackage
          InstallCommand="/q /norestart /ChainingPackage &quot;[WixBundleName]&quot; /log &quot;[NetFx471FullLog].html&quot;"
          RepairCommand="/q /norestart /repair /ChainingPackage &quot;[WixBundleName]&quot; /log &quot;[NetFx471FullLog].html&quot;"
          UninstallCommand="/uninstall /q /norestart /ChainingPackage &quot;[WixBundleName]&quot; /log &quot;[NetFx471FullLog].html&quot;"
          PerMachine="yes"
          DetectCondition="!(wix.NetFx471RedistDetectCondition)"
          InstallCondition="!(wix.NetFx471RedistInstallCondition)"
          Id="NetFx471Redist"
          Vital="yes"
          Permanent="yes"
          Protocol="netfx4"
          DownloadUrl="$(var.NetFx471RedistLink)"
          LogPathVariable="NetFx471FullLog"
          Compressed="no"
          Name="!(wix.NetFx471RedistPackageDirectory)NDP471-KB4033342-x86-x64-AllOS-ENU.exe">
        <RemotePayload
          CertificatePublicKey="2ECAEC21B884B40A7C5FB141D2CBC4CDA4930752"
          CertificateThumbprint="49D59D86505D82942A076388693F4FB7B21254EE"
          Description="Microsoft .NET Framework 4.7.1 Setup"
          Hash="5F0597CEADDBDF3BAD24CA6EBE142BD81C2DF713"
          ProductName="Microsoft .NET Framework 4.7.1"
          Size="68742112"
          Version="4.7.2558.0" />
      </ExePackage>
    </PackageGroup>
  </Fragment>
</Wix>

and then in bundle.wxs you need to add this: 然后在bundle.wxs中你需要添加这个:

  <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

  <Bundle Name="..."
          Version="..." 
          Manufacturer="..." 
          UpgradeCode="..." 
          >

    <Chain>      

      <!--Install .Net Framework 4.7.1-->
      <PackageGroupRef Id="NetFx471Redist"/>

      <!--Install Product-->
      <MsiPackage
        Id="Setup"   
        DisplayInternalUI="yes"
        Compressed="yes"
        SourceFile="..."
        Vital="yes">        
      </MsiPackage>     

    </Chain>
  </Bundle>  
</Wix>

I found it bit misleading that the question is about 4.7.2 but the accepted answer about 4.7.1 version. 我发现有点误导,问题是关于4.7.2但是关于4.7.1版本的公认答案。

All the exact bits are here . 所有确切的位都在这里

Just tested on a computer without 4.7.2 installed and all worked perfectly - the installer downloaded and installed .NET Framework component and first then it continued with the program installation itself. 刚刚在未安装4.7.2的计算机上进行测试,所有工作都完美 - 安装程序下载并安装了.NET Framework组件,然后继续进行程序安装。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM