From 9969392ff7024d2f1e257c2f6c5ce31fa0e839d3 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Mon, 6 Apr 2020 12:27:53 +1000 Subject: BalWindowsInstallerBackendBinderExtension is supposed to be a BurnBackendExtension. --- src/wixext/BalBurnBackendExtension.cs | 129 ++++++++++++++++++ src/wixext/BalExtensionFactory.cs | 2 +- .../BalWindowsInstallerBackendBinderExtension.cs | 145 --------------------- src/wixext/WixToolset.Bal.wixext.csproj | 1 - src/wixext/tables.xml | 41 ------ 5 files changed, 130 insertions(+), 188 deletions(-) create mode 100644 src/wixext/BalBurnBackendExtension.cs delete mode 100644 src/wixext/BalWindowsInstallerBackendBinderExtension.cs delete mode 100644 src/wixext/tables.xml (limited to 'src') diff --git a/src/wixext/BalBurnBackendExtension.cs b/src/wixext/BalBurnBackendExtension.cs new file mode 100644 index 00000000..20609964 --- /dev/null +++ b/src/wixext/BalBurnBackendExtension.cs @@ -0,0 +1,129 @@ +// 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. + +namespace WixToolset.Bal +{ + using System; + using System.Linq; + using WixToolset.Data; + using WixToolset.Data.Burn; + using WixToolset.Data.WindowsInstaller; + using WixToolset.Data.WindowsInstaller.Rows; + using WixToolset.Extensibility; + using WixToolset.Extensibility.Data; + + public class BalBurnBackendExtension : BaseBurnBackendExtension + { + public override void PostBackendBind(IBindResult result) + { + base.PostBackendBind(result); + + var output = WindowsInstallerData.Load(result.Wixout, false); + + // Only process Bundles. + if (OutputType.Bundle != output.Type) + { + return; + } + + var baTable = output.Tables["WixBootstrapperApplication"]; + var baRow = baTable.Rows[0]; + var baId = (string)baRow[0]; + if (null == baId) + { + return; + } + + var isStdBA = baId.StartsWith("WixStandardBootstrapperApplication"); + var isMBA = baId.StartsWith("ManagedBootstrapperApplicationHost"); + + if (isStdBA || isMBA) + { + this.VerifyBAFunctions(output); + } + + if (isMBA) + { + this.VerifyPrereqPackages(output); + } + } + + private void VerifyBAFunctions(WindowsInstallerData output) + { + Row baFunctionsRow = null; + var baFunctionsTable = output.Tables["WixBalBAFunctions"]; + foreach (var row in baFunctionsTable.Rows) + { + if (null == baFunctionsRow) + { + baFunctionsRow = row; + } + else + { + this.Messaging.Write(BalErrors.MultipleBAFunctions(row.SourceLineNumbers)); + } + } + + var payloadPropertiesTable = output.Tables["WixPayloadProperties"]; + var payloadPropertiesRows = payloadPropertiesTable.Rows.Cast(); + if (null == baFunctionsRow) + { + foreach (var payloadPropertiesRow in payloadPropertiesRows) + { + // TODO: Make core WiX canonicalize Name (this won't catch '.\bafunctions.dll'). + if (string.Equals(payloadPropertiesRow.Name, "bafunctions.dll", StringComparison.OrdinalIgnoreCase)) + { + this.Messaging.Write(BalWarnings.UnmarkedBAFunctionsDLL(payloadPropertiesRow.SourceLineNumbers)); + } + } + } + else + { + // TODO: May need to revisit this depending on the outcome of #5273. + var payloadId = (string)baFunctionsRow[0]; + var bundlePayloadRow = payloadPropertiesRows.Single(x => payloadId == x.Id); + if (BurnConstants.BurnUXContainerName != bundlePayloadRow.Container) + { + this.Messaging.Write(BalErrors.BAFunctionsPayloadRequiredInUXContainer(baFunctionsRow.SourceLineNumbers)); + } + } + } + + private void VerifyPrereqPackages(WindowsInstallerData output) + { + var prereqInfoTable = output.Tables["WixMbaPrereqInformation"]; + if (null == prereqInfoTable || prereqInfoTable.Rows.Count == 0) + { + this.Messaging.Write(BalErrors.MissingPrereq()); + return; + } + + var foundLicenseFile = false; + var foundLicenseUrl = false; + + foreach (Row prereqInfoRow in prereqInfoTable.Rows) + { + if (null != prereqInfoRow[1]) + { + if (foundLicenseFile || foundLicenseUrl) + { + this.Messaging.Write(BalErrors.MultiplePrereqLicenses(prereqInfoRow.SourceLineNumbers)); + return; + } + + foundLicenseFile = true; + } + + if (null != prereqInfoRow[2]) + { + if (foundLicenseFile || foundLicenseUrl) + { + this.Messaging.Write(BalErrors.MultiplePrereqLicenses(prereqInfoRow.SourceLineNumbers)); + return; + } + + foundLicenseUrl = true; + } + } + } + } +} diff --git a/src/wixext/BalExtensionFactory.cs b/src/wixext/BalExtensionFactory.cs index 936686a6..30ec88c3 100644 --- a/src/wixext/BalExtensionFactory.cs +++ b/src/wixext/BalExtensionFactory.cs @@ -12,7 +12,7 @@ namespace WixToolset.Bal { typeof(BalCompiler), typeof(BalExtensionData), - typeof(BalWindowsInstallerBackendBinderExtension), + typeof(BalBurnBackendExtension), }; } } diff --git a/src/wixext/BalWindowsInstallerBackendBinderExtension.cs b/src/wixext/BalWindowsInstallerBackendBinderExtension.cs deleted file mode 100644 index 3c116329..00000000 --- a/src/wixext/BalWindowsInstallerBackendBinderExtension.cs +++ /dev/null @@ -1,145 +0,0 @@ -// 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. - -namespace WixToolset.Bal -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Xml; - using WixToolset.Data; - using WixToolset.Data.Burn; - using WixToolset.Data.WindowsInstaller; - using WixToolset.Data.WindowsInstaller.Rows; - using WixToolset.Extensibility; - using WixToolset.Extensibility.Data; - - public class BalWindowsInstallerBackendBinderExtension : BaseWindowsInstallerBackendBinderExtension - { - private static readonly TableDefinition[] Tables = LoadTables(); - - public override IEnumerable TableDefinitions => Tables; - - private static TableDefinition[] LoadTables() - { - using (var resourceStream = typeof(BalWindowsInstallerBackendBinderExtension).Assembly.GetManifestResourceStream("WixToolset.Bal.tables.xml")) - using (var reader = XmlReader.Create(resourceStream)) - { - var tables = TableDefinitionCollection.Load(reader); - return tables.ToArray(); - } - } - - public override void PostBackendBind(IBindResult result) - { - base.PostBackendBind(result); - - var output = WindowsInstallerData.Load(result.Wixout, false); - - // Only process Bundles. - if (OutputType.Bundle != output.Type) - { - return; - } - - var baTable = output.Tables["WixBootstrapperApplication"]; - var baRow = baTable.Rows[0]; - var baId = (string)baRow[0]; - if (null == baId) - { - return; - } - - var isStdBA = baId.StartsWith("WixStandardBootstrapperApplication"); - var isMBA = baId.StartsWith("ManagedBootstrapperApplicationHost"); - - if (isStdBA || isMBA) - { - this.VerifyBAFunctions(output); - } - - if (isMBA) - { - this.VerifyPrereqPackages(output); - } - } - - private void VerifyBAFunctions(WindowsInstallerData output) - { - Row baFunctionsRow = null; - var baFunctionsTable = output.Tables["WixBalBAFunctions"]; - foreach (var row in baFunctionsTable.Rows) - { - if (null == baFunctionsRow) - { - baFunctionsRow = row; - } - else - { - this.Messaging.Write(BalErrors.MultipleBAFunctions(row.SourceLineNumbers)); - } - } - - var payloadPropertiesTable = output.Tables["WixPayloadProperties"]; - var payloadPropertiesRows = payloadPropertiesTable.Rows.Cast(); - if (null == baFunctionsRow) - { - foreach (var payloadPropertiesRow in payloadPropertiesRows) - { - // TODO: Make core WiX canonicalize Name (this won't catch '.\bafunctions.dll'). - if (string.Equals(payloadPropertiesRow.Name, "bafunctions.dll", StringComparison.OrdinalIgnoreCase)) - { - this.Messaging.Write(BalWarnings.UnmarkedBAFunctionsDLL(payloadPropertiesRow.SourceLineNumbers)); - } - } - } - else - { - // TODO: May need to revisit this depending on the outcome of #5273. - var payloadId = (string)baFunctionsRow[0]; - var bundlePayloadRow = payloadPropertiesRows.Single(x => payloadId == x.Id); - if (BurnConstants.BurnUXContainerName != bundlePayloadRow.Container) - { - this.Messaging.Write(BalErrors.BAFunctionsPayloadRequiredInUXContainer(baFunctionsRow.SourceLineNumbers)); - } - } - } - - private void VerifyPrereqPackages(WindowsInstallerData output) - { - var prereqInfoTable = output.Tables["WixMbaPrereqInformation"]; - if (null == prereqInfoTable || prereqInfoTable.Rows.Count == 0) - { - this.Messaging.Write(BalErrors.MissingPrereq()); - return; - } - - var foundLicenseFile = false; - var foundLicenseUrl = false; - - foreach (Row prereqInfoRow in prereqInfoTable.Rows) - { - if (null != prereqInfoRow[1]) - { - if (foundLicenseFile || foundLicenseUrl) - { - this.Messaging.Write(BalErrors.MultiplePrereqLicenses(prereqInfoRow.SourceLineNumbers)); - return; - } - - foundLicenseFile = true; - } - - if (null != prereqInfoRow[2]) - { - if (foundLicenseFile || foundLicenseUrl) - { - this.Messaging.Write(BalErrors.MultiplePrereqLicenses(prereqInfoRow.SourceLineNumbers)); - return; - } - - foundLicenseUrl = true; - } - } - } - } -} diff --git a/src/wixext/WixToolset.Bal.wixext.csproj b/src/wixext/WixToolset.Bal.wixext.csproj index 49f891d3..aef4c4d9 100644 --- a/src/wixext/WixToolset.Bal.wixext.csproj +++ b/src/wixext/WixToolset.Bal.wixext.csproj @@ -13,7 +13,6 @@ - diff --git a/src/wixext/tables.xml b/src/wixext/tables.xml deleted file mode 100644 index 18abf1d7..00000000 --- a/src/wixext/tables.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- cgit v1.2.3-55-g6feb