先决条件未在条件失败时运行

Posted

技术标签:

【中文标题】先决条件未在条件失败时运行【英文标题】:Prerequisite not running on condition failure 【发布时间】:2014-01-17 21:46:20 【问题描述】:

我有一个 Burn 包 (WIX 3.7),如果运行包的系统上不存在 .NET 4.5 框架,它应该安装它。

这是包含先决条件的片段:

<Fragment>
<WixVariable Id="WixMbaPrereqPackageId" Value="Netfx45FullPrereq" />
<WixVariable Id="WixMbaPrereqLicenseUrl" Value="NetFx45Eula.rtf" />

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

<PackageGroup
    Id="Netfx45FullPrereq">
  <ExePackage
      Id="Netfx45FullPrereq"
      Cache="no"
      Compressed="no"
      PerMachine="yes"
      Permanent="yes"
      Vital="yes"
      SourceFile="..\..\ThirdParty\Windows Installer\dotnetfx45_full_x86_x64.exe"
      Name="dotnetfx45_full_x86_x64.exe"
      InstallCommand="/passive /norestart"
      InstallCondition="NOT Netfx45Version OR (Netfx45Version &lt; v4.5.50709)"
      DetectCondition="Netfx45Version AND (Netfx45Version &gt;= v4.5.50709)" />
</PackageGroup>
</Fragment>

我让它在一台机器上工作,但是,在另一台机器上它不起作用。

以下是运行 .NET 安装程序的机器(Window Server 2008 R2)的日志:

[0B68:0D24][2014-01-17T16:27:24]i001: Burn v3.7.1224.0, Windows v6.1 (Build 7601: Service Pack 1), path: C:\Users\Administrator\Desktop\ProductName Installer\ProductName Setup.exe, cmdline: '-burn.unelevated BurnPipe.27DB9848-09B3-4E3A-8CF3-D27BE5508398 57F2A2B4-8B66-41E6-9488-A18E40965A62 3848'
[0B68:0D24][2014-01-17T16:27:24]i000: Setting string variable 'WixBundleLog' to value 'C:\Users\ADMINI~1\AppData\Local\Temp\ProductName_20140117162724.log'
[0B68:0D24][2014-01-17T16:27:24]i000: Setting string variable 'WixBundleOriginalSource' to value 'C:\Users\Administrator\Desktop\ProductName Installer\ProductName Setup.exe'
[0B68:0D24][2014-01-17T16:27:24]i000: Loading prerequisite bootstrapper application because managed host could not be loaded, error: 0x80070490.
[0B68:0D24][2014-01-17T16:27:24]i100: Detect begin, 3 packages
[0B68:0D24][2014-01-17T16:27:24]i000: Registry key not found. Key = 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full'
[0B68:0D24][2014-01-17T16:27:24]i102: Detected related bundle: 014bc187-ac3e-49eb-a86b-bc1aff00df4e, type: Upgrade, scope: PerMachine, version: 0.6.0.0, operation: None
[0B68:0D24][2014-01-17T16:27:24]i102: Detected related bundle: 2171cc02-2faf-4e06-bd43-fa473ed5fa20, type: Upgrade, scope: PerMachine, version: 0.6.0.0, operation: None
[0B68:0D24][2014-01-17T16:27:24]i102: Detected related bundle: 4240a35a-bf8b-4465-97c1-3e2653e34c25, type: Upgrade, scope: PerMachine, version: 0.6.0.0, operation: None
[0B68:0D24][2014-01-17T16:27:24]i102: Detected related bundle: 5e33e695-3dc7-4871-a059-9965bc8c76d6, type: Upgrade, scope: PerMachine, version: 0.6.0.0, operation: None
[0B68:0D24][2014-01-17T16:27:24]i102: Detected related bundle: 6f2e85ba-1010-4870-94a7-9e220b8d80cc, type: Upgrade, scope: PerMachine, version: 0.6.0.0, operation: None
[0B68:0D24][2014-01-17T16:27:24]i102: Detected related bundle: aa47b386-8505-4de6-90e5-78a7d0ce37e0, type: Upgrade, scope: PerMachine, version: 0.6.0.0, operation: None
[0B68:0D24][2014-01-17T16:27:24]i102: Detected related bundle: c6564625-564f-4b3c-b91f-7bcde363a62f, type: Upgrade, scope: PerMachine, version: 0.6.0.0, operation: None
[0B68:0D24][2014-01-17T16:27:24]i102: Detected related bundle: cd20283a-14f4-4b5d-bca9-f16d992948c4, type: Upgrade, scope: PerMachine, version: 0.6.0.0, operation: None
[0B68:0D24][2014-01-17T16:27:24]i102: Detected related bundle: f0c01f09-d2bb-4a26-9aac-c2be4d9b02da, type: Upgrade, scope: PerMachine, version: 0.6.0.0, operation: None
[0B68:0D24][2014-01-17T16:27:24]i102: Detected related bundle: f642578c-7e94-4a7e-b884-870a844c9177, type: Upgrade, scope: PerMachine, version: 0.6.0.0, operation: None
[0B68:0D24][2014-01-17T16:27:24]i052: Condition 'NETFRAMEWORK45' evaluates to false.
[0B68:0D24][2014-01-17T16:27:24]i101: Detected package: Netfx45FullPrereq, state: Absent, cached: None
[0B68:0D24][2014-01-17T16:27:24]i101: Detected package: ProductNameSetup, state: Absent, cached: None
[0B68:0D24][2014-01-17T16:27:24]i104: Detected package: ProductNameSetup, feature: DatabaseFeature, state: Absent
[0B68:0D24][2014-01-17T16:27:24]i104: Detected package: ProductNameSetup, feature: InfrastructureFeature, state: Absent
[0B68:0D24][2014-01-17T16:27:24]i199: Detect complete, result: 0x0

以下是未显示 .NET 安装程序的机器 (Windows 7) 的日志:

[0B78:0B00][2014-01-17T20:02:44]i001: Burn v3.7.1224.0, Windows v6.1 (Build 7601: Service Pack 1), path: C:\Users\Master of Puppets\Desktop\Release\ProductName Setup.exe, cmdline: '-burn.unelevated BurnPipe.923B76FF-EE93-4FF9-9115-31A62D349563 7BA5CB98-B614-4EF6-B014-7EEA687287A9 2124'
[0B78:0B00][2014-01-17T20:02:44]i000: Setting string variable 'WixBundleLog' to value 'C:\Users\MASTER~1\AppData\Local\Temp\ProductName_20140117200244.log'
[0B78:0B00][2014-01-17T20:02:44]i000: Setting string variable 'WixBundleOriginalSource' to value 'C:\Users\Master of Puppets\Desktop\Release\ProductName Setup.exe'
[0B78:0B00][2014-01-17T20:02:44]i000: Setting string variable 'WixBundleName' to value 'ProductName'
[0B78:0B00][2014-01-17T20:02:44]i000: Loading managed bootstrapper application.
[0B78:0B00][2014-01-17T20:02:44]i000: Creating BA thread to run asynchronously.
[0B78:0B00][2014-01-17T20:02:45]i100: Detect begin, 3 packages
[0B78:0B00][2014-01-17T20:02:45]i000: Registry value not found. Key = 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full', Value = 'Release'
[0B78:0B00][2014-01-17T20:02:45]i052: Condition 'NETFRAMEWORK45' evaluates to false.
[0B78:0B00][2014-01-17T20:02:45]i101: Detected package: Netfx45FullPrereq, state: Absent, cached: None
[0B78:0B00][2014-01-17T20:02:45]i101: Detected package: ProductNameSetup, state: Absent, cached: None
[0B78:0B00][2014-01-17T20:02:45]i104: Detected package: ProductNameSetup, feature: DatabaseFeature, state: Absent
[0B78:0B00][2014-01-17T20:02:45]i104: Detected package: ProductNameSetup, feature: InfrastructureFeature, state: Absent
[0B78:0B00][2014-01-17T20:02:45]i199: Detect complete, result: 0x0
[0B78:0B00][2014-01-17T20:02:49]i500: Shutting down, exit code: 0x0
[0B78:0B00][2014-01-17T20:02:49]i410: Variable: WixBundleAction = 4
[0B78:0B00][2014-01-17T20:02:49]i410: Variable: WixBundleElevated = 1
[0B78:0B00][2014-01-17T20:02:49]i410: Variable: WixBundleLog = C:\Users\MASTER~1\AppData\Local\Temp\ProductName_20140117200244.log
[0B78:0B00][2014-01-17T20:02:49]i410: Variable: WixBundleManufacturer = CompanyName
[0B78:0B00][2014-01-17T20:02:49]i410: Variable: WixBundleName = ProductName
[0B78:0B00][2014-01-17T20:02:49]i410: Variable: WixBundleOriginalSource = C:\Users\Master of Puppets\Desktop\Release\ProductName Setup.exe
[0B78:0B00][2014-01-17T20:02:49]i410: Variable: WixBundleProviderKey = d62f0df8-e5e6-4fc6-9924-202de1286a25
[0B78:0B00][2014-01-17T20:02:49]i410: Variable: WixBundleTag = 
[0B78:0B00][2014-01-17T20:02:49]i410: Variable: WixBundleVersion = 0.6.0.0
[0B78:0B00][2014-01-17T20:02:49]i007: Exit code: 0x0, restarting: No

在这两种情况下,检测条件都返回 false,我认为这会触发 .NET 安装程序运行。显然情况并非如此,我不确定为什么我会得到两种不同的行为。有谁知道为什么它会在一台机器上运行而不是另一台机器上运行?

【问题讨论】:

您是否愿意让您的引导程序下载 .NET Framework 并进行安装,还是需要将其嵌入以进行离线安装? 您是否尝试过在您的 Windows 7 计算机上从命令行使用 /passive /norestart 调用 dotnetfx45_full_x86_x64.exe 并查看会发生什么? 无法下载。这是客户的要求。 @PaulyGlott 如果我从命令行使用/passive /norestart 参数运行包,它将运行.NET 安装程序。 【参考方案1】:

它不起作用的原因是我没有在我的 BootstrapperCore.config 文件的支持的运行时元素中设置 sku 属性。这是我的启动元素现在的样子:

<startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>

【讨论】:

【参考方案2】:

您尚未为包指定 InstallCondition。你必须有这样的东西:InstallCondition = (NOT NETFRAMEWORK45 ="4.5.50709")

【讨论】:

我现在使用这两个条件,得到相同的结果:InstallCondition="NOT Netfx45Version OR (Netfx45Version &amp;lt; v4.5.50709)"DetectCondition="Netfx45Version AND (Netfx45Version &amp;gt;= v4.5.50709)" /&gt; 我用新的片段元素更新了问题。 如果比较两者的日志文件,是有区别的。在 Windows Server 2008 的情况下,注册表 KEY 不存在:"Registry key not found. Key = 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full'" 但在 Windows 7 的情况下,注册表项存在,只是缺少值“找不到注册表值。键 = 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full', Value = 'Release'” 是的,但是两台机器都评估为假。并且使用版本号而不是“发布”键仍然会产生相同的行为。

以上是关于先决条件未在条件失败时运行的主要内容,如果未能解决你的问题,请参考以下文章

仅当上一步失败时如何在 Jenkins 中运行条件步骤

Recyclerview 项目在适配器中应用条件时未在 cardview 中显示数据

反应:条件类名称未在 DOM 中更新

32. 安装oracle11g时,先决条件一直失败的解决方法

Thymeleaf 模板未在条件内呈现参数值

Oracle安装过程出现问题---------安装Oracle11gR2先决条件检查失败