如何使用 WiX Burn 智能安装 .NET 4.x [英] How to intelligently install .NET 4.x using WiX Burn

查看:26
本文介绍了如何使用 WiX Burn 智能安装 .NET 4.x的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

安装可使用 .NET 4.0 或 4.5 的应用程序时,安装必备 .NET 框架的最佳做法是什么?您如何在 WiX 中使用 Burn 实现它?

When installing an application that can use either .NET 4.0 or 4.5, what is the best practice when installing the prerequisites .NET framework? And how do you implement it using Burn in WiX?

这些是我所知道的选项和权衡:

These are the options and trade-offs that I am aware of:

选项 1:安装 .NET 4.0(正是您需要的)

  • 优点:未知(除了 Windows XP,这是唯一的选择)

选项 2:如果 .NET 4.5 不存在,则安装 .NET 4.5

  • 优点:用户以后不必安装 .NET 4.5 以备将来使用应用.当用户稍后更改时,应用程序不会遇到 .NET 版本更改升级到 .NET 4.5.应用程序立即获得性能改进.NET 4.5.

选项 3:仅当 .NET 4.x 都不存在时才安装 .NET 4.5

  • 优点:如果是 .NET 4.0,则部署比选项 2 快得多已安装.如果不是,那么选项 2 的优点申请.

据我所知,如果性能改进很重要,最佳做法是选项 2,如果平均部署速度很重要,则最佳做法是选项 3.这听起来对吗?我是否错过了选项 1 的任何优势?最重要的是,如果选项 3 确实有意义,那么在从 Web 安装 .NET 时如何使用 Burn 实现它?

As far as I can tell, the best practice would be option 2 if the performance improvements are important and option 3 if average deployment speed is important. Does this sound right? Am I missing any advantage to option 1? Most importantly, if option 3 does make sense, how do you implement it using Burn when installing .NET from the web?

推荐答案

下面是我如何在我的包中检测 .NET.请注意 DetectConditions 和 InstallConditions 的使用.DetectCondition 将检查是否安装了特定的包,而 InstallCondition 可用于覆盖 DetectCondition 以指定应安装包的时间.例如,在 XP 上您无法安装 .NET 4.5,因此我的 InstallCondition 会阻止安装.

Below is how I detect .NET in my bundle. Note the use of DetectConditions and InstallConditions. The DetectCondition will check whether or not the specific package is installed, whereas the InstallCondition can be used to override the DetectCondition to specify when the package should be installed. For example, on XP you can't install .NET 4.5 so my InstallCondition prevents installation in such a case.

<util:RegistrySearch Root="HKLM" Key="SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Full" Value="Version" Variable="Netfx4FullVersion" />
<util:RegistrySearch Root="HKLM" Key="SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Full" Value="Version" Variable="Netfx4x64FullVersion" Win64="yes" />

<!-- .NET 4.5 only installed if Vista or higher AND it's not already installed-->
<PackageGroup Id="Netfx45">
  <ExePackage Id="Netfx45" Cache="no" Compressed="yes" PerMachine="yes" Permanent="yes" Vital="yes" InstallCommand="/q"
              SourceFile="C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages\DotNetFX45Full\dotnetfx45_full_x86_x64.exe"
              DetectCondition="(Netfx4FullVersion=&quot;4.5.50709&quot;) AND (NOT VersionNT64 OR (Netfx4x64FullVersion=&quot;4.5.50709&quot;))"
              InstallCondition="(VersionNT >= v6.0 OR VersionNT64 >= v6.0) AND (NOT (Netfx4FullVersion=&quot;4.5.50709&quot; OR Netfx4x64FullVersion=&quot;4.5.50709&quot;))"/>
</PackageGroup>
<!-- .NET 4.0 only installed if XP AND it's not already installed -->
<PackageGroup Id="Netfx4Full">
  <ExePackage Id="Netfx4Full" Cache="no" Compressed="yes" PerMachine="yes" Permanent="yes" Vital="yes" InstallCommand="/q"
              SourceFile="C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages\DotNetFX40\dotNetFx40_Full_x86_x64.exe"
              DetectCondition="Netfx4FullVersion AND (NOT VersionNT64 OR Netfx4x64FullVersion)"
              InstallCondition="(VersionNT &lt; v6.0 OR VersionNT64 &lt; v6.0) AND (NOT (Netfx4FullVersion OR Netfx4x64FullVersion))"/>
</PackageGroup>

然后,如果您想安装其中一个软件包,只需在您的链中引用它:

Then if you want to install one of the packages, just reference it in your chain:

<Chain>
  <PackageGroupRef Id='Netfx45'/>
</Chain>

关于您的具体问题,我会安装应用程序测试所针对的任何框架版本.如果针对 .NET 4.0 和 .NET 4.5 进行测试,我想这是一个判断调用,但是我会尽量简化设置体验.因此,如果 .NET 4.0 已经安装并且应用程序不需要 .NET 4.5,我不会安装它.

With regards to your specific question, I would install whatever framework version the application was tested against. If tested against both .NET 4.0 and .NET 4.5 I suppose it is a judgement call, however I would try to simplify the setup experience as much as possible. So if .NET 4.0 were already installed and the application does not require .NET 4.5, I would not install it.

此外,如果您使用自定义托管引导程序应用程序,则选项 2 有一个缺点.假设您安装了 .NET 4.0,并且您的托管引导程序需要 .NET 4.0(或更高版本).当您运行安装程序时,它将安装 .NET 4.5,它取代了 .NET 4.0,迫使您的安装程序中途重新启动,因为它在更新的同时使用 .NET 框架.同样,如果您使用自己的自定义托管引导程序,这只是一个问题.

Also, there is a disadvantage to Option 2 if you are using a custom Managed Bootstrapper Application. Let's say you have .NET 4.0 installed and your managed bootstrapper requires .NET 4.0 (or greater). When you run the installer it will install .NET 4.5 which replaces .NET 4.0, forcing your installer to reboot halfway through because it was using .NET framework at the same time it was being updated. Again, this is only an issue if you are using your own custom managed bootstrapper.

这篇关于如何使用 WiX Burn 智能安装 .NET 4.x的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆