From ea864b56d115e4f7a7205827ecaaba0e1db81d41 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Mon, 31 Dec 2018 23:57:35 -0600 Subject: Integrate into latest v4. --- src/wixext/BalBinder.cs | 125 ---------- src/wixext/BalCompiler.cs | 266 +++++++++++---------- src/wixext/BalErrors.cs | 55 +++++ src/wixext/BalExtensionData.cs | 45 +--- src/wixext/BalExtensionFactory.cs | 18 ++ src/wixext/BalWarnings.cs | 31 +++ .../BalWindowsInstallerBackendBinderExtension.cs | 146 +++++++++++ src/wixext/Tuples/BalTupleDefinitions.cs | 55 +++++ src/wixext/Tuples/WixBalBAFunctionsTuple.cs | 47 ++++ src/wixext/Tuples/WixBalConditionTuple.cs | 55 +++++ src/wixext/Tuples/WixMbaPrereqInformationTuple.cs | 63 +++++ src/wixext/Tuples/WixStdbaOptionsTuple.cs | 79 ++++++ .../Tuples/WixStdbaOverridableVariableTuple.cs | 47 ++++ src/wixext/WixBalExtension.csproj | 47 ---- src/wixext/WixToolset.Bal.wixext.csproj | 30 +++ src/wixext/WixToolset.Bal.wixext.targets | 11 + src/wixext/messages.xml | 43 ---- 17 files changed, 782 insertions(+), 381 deletions(-) delete mode 100644 src/wixext/BalBinder.cs create mode 100644 src/wixext/BalErrors.cs create mode 100644 src/wixext/BalExtensionFactory.cs create mode 100644 src/wixext/BalWarnings.cs create mode 100644 src/wixext/BalWindowsInstallerBackendBinderExtension.cs create mode 100644 src/wixext/Tuples/BalTupleDefinitions.cs create mode 100644 src/wixext/Tuples/WixBalBAFunctionsTuple.cs create mode 100644 src/wixext/Tuples/WixBalConditionTuple.cs create mode 100644 src/wixext/Tuples/WixMbaPrereqInformationTuple.cs create mode 100644 src/wixext/Tuples/WixStdbaOptionsTuple.cs create mode 100644 src/wixext/Tuples/WixStdbaOverridableVariableTuple.cs delete mode 100644 src/wixext/WixBalExtension.csproj create mode 100644 src/wixext/WixToolset.Bal.wixext.csproj create mode 100644 src/wixext/WixToolset.Bal.wixext.targets delete mode 100644 src/wixext/messages.xml (limited to 'src/wixext') diff --git a/src/wixext/BalBinder.cs b/src/wixext/BalBinder.cs deleted file mode 100644 index 30f7ab44..00000000 --- a/src/wixext/BalBinder.cs +++ /dev/null @@ -1,125 +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.Extensions -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; - using WixToolset; - using WixToolset.Data; - using WixToolset.Data.Rows; - using WixToolset.Extensibility; - - public class BalBinder : BinderExtension - { - public override void Finish(Output output) - { - // Only process Bundles. - if (OutputType.Bundle != output.Type) - { - return; - } - - Table baTable = output.Tables["WixBootstrapperApplication"]; - Row baRow = baTable.Rows[0]; - string baId = (string)baRow[0]; - if (null == baId) - { - return; - } - - bool isStdBA = baId.StartsWith("WixStandardBootstrapperApplication"); - bool isMBA = baId.StartsWith("ManagedBootstrapperApplicationHost"); - - if (isStdBA || isMBA) - { - VerifyBAFunctions(output); - } - - if (isMBA) - { - VerifyPrereqPackages(output); - } - } - - private void VerifyBAFunctions(Output output) - { - Row baFunctionsRow = null; - Table baFunctionsTable = output.Tables["WixBalBAFunctions"]; - foreach (Row row in baFunctionsTable.RowsAs()) - { - if (null == baFunctionsRow) - { - baFunctionsRow = row; - } - else - { - this.Core.OnMessage(BalErrors.MultipleBAFunctions(row.SourceLineNumbers)); - } - } - - Table payloadPropertiesTable = output.Tables["WixPayloadProperties"]; - IEnumerable payloadPropertiesRows = payloadPropertiesTable.RowsAs(); - if (null == baFunctionsRow) - { - foreach (WixPayloadPropertiesRow 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.Core.OnMessage(BalWarnings.UnmarkedBAFunctionsDLL(payloadPropertiesRow.SourceLineNumbers)); - } - } - } - else - { - // TODO: May need to revisit this depending on the outcome of #5273. - string payloadId = (string)baFunctionsRow[0]; - WixPayloadPropertiesRow bundlePayloadRow = payloadPropertiesRows.Single(x => payloadId == x.Id); - if (Compiler.BurnUXContainerId != bundlePayloadRow.Container) - { - this.Core.OnMessage(BalErrors.BAFunctionsPayloadRequiredInUXContainer(baFunctionsRow.SourceLineNumbers)); - } - } - } - - private void VerifyPrereqPackages(Output output) - { - Table prereqInfoTable = output.Tables["WixMbaPrereqInformation"]; - if (null == prereqInfoTable || prereqInfoTable.Rows.Count == 0) - { - this.Core.OnMessage(BalErrors.MissingPrereq()); - return; - } - - bool foundLicenseFile = false; - bool foundLicenseUrl = false; - - foreach (Row prereqInfoRow in prereqInfoTable.Rows) - { - if (null != prereqInfoRow[1]) - { - if (foundLicenseFile || foundLicenseUrl) - { - this.Core.OnMessage(BalErrors.MultiplePrereqLicenses(prereqInfoRow.SourceLineNumbers)); - return; - } - - foundLicenseFile = true; - } - - if (null != prereqInfoRow[2]) - { - if (foundLicenseFile || foundLicenseUrl) - { - this.Core.OnMessage(BalErrors.MultiplePrereqLicenses(prereqInfoRow.SourceLineNumbers)); - return; - } - - foundLicenseUrl = true; - } - } - } - } -} diff --git a/src/wixext/BalCompiler.cs b/src/wixext/BalCompiler.cs index 38ca9e3c..5b54ef58 100644 --- a/src/wixext/BalCompiler.cs +++ b/src/wixext/BalCompiler.cs @@ -1,21 +1,22 @@ // 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.Extensions +namespace WixToolset.Bal { using System; using System.Collections.Generic; using System.Xml.Linq; + using WixToolset.Bal.Tuples; using WixToolset.Data; - using WixToolset.Data.Rows; + using WixToolset.Data.Tuples; using WixToolset.Extensibility; /// /// The compiler for the WiX Toolset Bal Extension. /// - public sealed class BalCompiler : CompilerExtension + public sealed class BalCompiler : BaseCompilerExtension { private SourceLineNumber addedConditionLineNumber; - private Dictionary prereqInfoRows; + private Dictionary prereqInfoRows; /// /// Instantiate a new BalCompiler. @@ -23,17 +24,20 @@ namespace WixToolset.Extensions public BalCompiler() { this.addedConditionLineNumber = null; - prereqInfoRows = new Dictionary(); - this.Namespace = "http://wixtoolset.org/schemas/v4/wxs/bal"; + this.prereqInfoRows = new Dictionary(); } + public override XNamespace Namespace => "http://wixtoolset.org/schemas/v4/wxs/bal"; + /// /// Processes an element for the Compiler. /// + /// + /// /// Parent element of element to process. /// Element to process. - /// Extra information about the context in which this element is being parsed. - public override void ParseElement(XElement parentElement, XElement element, IDictionary context) + /// Extra information about the context in which this element is being parsed. + public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context) { switch (parentElement.Name.LocalName) { @@ -42,10 +46,10 @@ namespace WixToolset.Extensions switch (element.Name.LocalName) { case "Condition": - this.ParseConditionElement(element); + this.ParseConditionElement(intermediate, section, element); break; default: - this.Core.UnexpectedElement(parentElement, element); + this.ParseHelper.UnexpectedElement(parentElement, element); break; } break; @@ -53,18 +57,18 @@ namespace WixToolset.Extensions switch (element.Name.LocalName) { case "WixStandardBootstrapperApplication": - this.ParseWixStandardBootstrapperApplicationElement(element); + this.ParseWixStandardBootstrapperApplicationElement(intermediate, section, element); break; case "WixManagedBootstrapperApplicationHost": - this.ParseWixManagedBootstrapperApplicationHostElement(element); + this.ParseWixManagedBootstrapperApplicationHostElement(intermediate, section, element); break; default: - this.Core.UnexpectedElement(parentElement, element); + this.ParseHelper.UnexpectedElement(parentElement, element); break; } break; default: - this.Core.UnexpectedElement(parentElement, element); + this.ParseHelper.UnexpectedElement(parentElement, element); break; } } @@ -76,10 +80,10 @@ namespace WixToolset.Extensions /// Parent element of element to process. /// Attribute to process. /// Extra information about the context in which this element is being parsed. - public override void ParseAttribute(XElement parentElement, XAttribute attribute, IDictionary context) + public override void ParseAttribute(Intermediate intermediate, IntermediateSection section, XElement parentElement, XAttribute attribute, IDictionary context) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(parentElement); - Row row; + SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(parentElement); + WixMbaPrereqInformationTuple prereqInfo; switch (parentElement.Name.LocalName) { @@ -90,7 +94,7 @@ namespace WixToolset.Extensions string packageId; if (!context.TryGetValue("PackageId", out packageId) || String.IsNullOrEmpty(packageId)) { - this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, parentElement.Name.LocalName, "Id", attribute.Name.LocalName)); + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, parentElement.Name.LocalName, "Id", attribute.Name.LocalName)); } else { @@ -98,80 +102,80 @@ namespace WixToolset.Extensions { case "PrereqLicenseFile": - if (!prereqInfoRows.TryGetValue(packageId, out row)) + if (!this.prereqInfoRows.TryGetValue(packageId, out prereqInfo)) { // at the time the extension attribute is parsed, the compiler might not yet have // parsed the PrereqPackage attribute, so we need to get it directly from the parent element. XAttribute prereqPackage = parentElement.Attribute(this.Namespace + "PrereqPackage"); - if (null != prereqPackage && YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, prereqPackage)) + if (null != prereqPackage && YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, prereqPackage)) { - row = this.Core.CreateRow(sourceLineNumbers, "WixMbaPrereqInformation"); - row[0] = packageId; + prereqInfo = (WixMbaPrereqInformationTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixMbaPrereqInformation"); + prereqInfo.PackageId = packageId; - prereqInfoRows.Add(packageId, row); + this.prereqInfoRows.Add(packageId, prereqInfo); } else { - this.Core.OnMessage(BalErrors.AttributeRequiresPrereqPackage(sourceLineNumbers, parentElement.Name.LocalName, "PrereqLicenseFile")); + this.Messaging.Write(BalErrors.AttributeRequiresPrereqPackage(sourceLineNumbers, parentElement.Name.LocalName, "PrereqLicenseFile")); break; } } - if (null != row[2]) + if (null != prereqInfo.LicenseUrl) { - this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttribute(sourceLineNumbers, parentElement.Name.LocalName, "PrereqLicenseFile", "PrereqLicenseUrl")); + this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, parentElement.Name.LocalName, "PrereqLicenseFile", "PrereqLicenseUrl")); } else { - row[1] = this.Core.GetAttributeValue(sourceLineNumbers, attribute); + prereqInfo.LicenseFile = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attribute); } break; case "PrereqLicenseUrl": - if (!prereqInfoRows.TryGetValue(packageId, out row)) + if (!this.prereqInfoRows.TryGetValue(packageId, out prereqInfo)) { // at the time the extension attribute is parsed, the compiler might not yet have // parsed the PrereqPackage attribute, so we need to get it directly from the parent element. XAttribute prereqPackage = parentElement.Attribute(this.Namespace + "PrereqPackage"); - if (null != prereqPackage && YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, prereqPackage)) + if (null != prereqPackage && YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, prereqPackage)) { - row = this.Core.CreateRow(sourceLineNumbers, "WixMbaPrereqInformation"); - row[0] = packageId; + prereqInfo = (WixMbaPrereqInformationTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixMbaPrereqInformation"); + prereqInfo.PackageId = packageId; - prereqInfoRows.Add(packageId, row); + this.prereqInfoRows.Add(packageId, prereqInfo); } else { - this.Core.OnMessage(BalErrors.AttributeRequiresPrereqPackage(sourceLineNumbers, parentElement.Name.LocalName, "PrereqLicenseUrl")); + this.Messaging.Write(BalErrors.AttributeRequiresPrereqPackage(sourceLineNumbers, parentElement.Name.LocalName, "PrereqLicenseUrl")); break; } } - if (null != row[1]) + if (null != prereqInfo.LicenseFile) { - this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttribute(sourceLineNumbers, parentElement.Name.LocalName, "PrereqLicenseUrl", "PrereqLicenseFile")); + this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, parentElement.Name.LocalName, "PrereqLicenseUrl", "PrereqLicenseFile")); } else { - row[2] = this.Core.GetAttributeValue(sourceLineNumbers, attribute); + prereqInfo.LicenseUrl = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attribute); } break; case "PrereqPackage": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attribute)) + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attribute)) { - if (!prereqInfoRows.TryGetValue(packageId, out row)) + if (!this.prereqInfoRows.TryGetValue(packageId, out prereqInfo)) { - row = this.Core.CreateRow(sourceLineNumbers, "WixMbaPrereqInformation"); - row[0] = packageId; + prereqInfo = (WixMbaPrereqInformationTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixMbaPrereqInformation"); + prereqInfo.PackageId = packageId; - prereqInfoRows.Add(packageId, row); + this.prereqInfoRows.Add(packageId, prereqInfo); } } break; default: - this.Core.UnexpectedAttribute(parentElement, attribute); + this.ParseHelper.UnexpectedAttribute(parentElement, attribute); break; } } @@ -180,21 +184,21 @@ namespace WixToolset.Extensions string payloadId; if (!context.TryGetValue("Id", out payloadId) || String.IsNullOrEmpty(payloadId)) { - this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, parentElement.Name.LocalName, "Id", attribute.Name.LocalName)); + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, parentElement.Name.LocalName, "Id", attribute.Name.LocalName)); } else { switch (attribute.Name.LocalName) { case "BAFunctions": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attribute)) + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attribute)) { - row = this.Core.CreateRow(sourceLineNumbers, "WixBalBAFunctions"); - row[0] = payloadId; + var tuple = (WixBalBAFunctionsTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixBalBAFunctions"); + tuple.PayloadId = payloadId; } break; default: - this.Core.UnexpectedAttribute(parentElement, attribute); + this.ParseHelper.UnexpectedAttribute(parentElement, attribute); break; } } @@ -205,21 +209,21 @@ namespace WixToolset.Extensions XAttribute variableName = parentElement.Attribute("Name"); if (null == variableName) { - this.Core.OnMessage(WixErrors.ExpectedParentWithAttribute(sourceLineNumbers, "Variable", "Overridable", "Name")); + this.Messaging.Write(ErrorMessages.ExpectedParentWithAttribute(sourceLineNumbers, "Variable", "Overridable", "Name")); } else { switch (attribute.Name.LocalName) { case "Overridable": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attribute)) + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attribute)) { - row = this.Core.CreateRow(sourceLineNumbers, "WixStdbaOverridableVariable"); - row[0] = variableName; + var tuple = (WixStdbaOverridableVariableTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixStdbaOverridableVariable"); + tuple.Name = variableName.Value; } break; default: - this.Core.UnexpectedAttribute(parentElement, attribute); + this.ParseHelper.UnexpectedAttribute(parentElement, attribute); break; } } @@ -231,10 +235,10 @@ namespace WixToolset.Extensions /// Parses a Condition element for Bundles. /// /// The element to parse. - private void ParseConditionElement(XElement node) + private void ParseConditionElement(Intermediate intermediate, IntermediateSection section, XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - string condition = this.Core.GetConditionInnerText(node); // condition is the inner text of the element. + SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); + string condition = this.ParseHelper.GetConditionInnerText(node); // condition is the inner text of the element. string message = null; foreach (XAttribute attrib in node.Attributes()) @@ -244,37 +248,37 @@ namespace WixToolset.Extensions switch (attrib.Name.LocalName) { case "Message": - message = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + message = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; default: - this.Core.UnexpectedAttribute(node, attrib); + this.ParseHelper.UnexpectedAttribute(node, attrib); break; } } else { - this.Core.ParseExtensionAttribute(node, attrib); + this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); } } - this.Core.ParseForExtensionElements(node); + this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); // Error check the values. if (String.IsNullOrEmpty(condition)) { - this.Core.OnMessage(WixErrors.ConditionExpected(sourceLineNumbers, node.Name.LocalName)); + this.Messaging.Write(ErrorMessages.ConditionExpected(sourceLineNumbers, node.Name.LocalName)); } if (null == message) { - this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Message")); + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Message")); } - if (!this.Core.EncounteredError) + if (!this.Messaging.EncounteredError) { - Row row = this.Core.CreateRow(sourceLineNumbers, "WixBalCondition"); - row[0] = condition; - row[1] = message; + var tuple = (WixBalConditionTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixBalCondition"); + tuple.Condition = condition; + tuple.Message = message; if (null == this.addedConditionLineNumber) { @@ -287,9 +291,9 @@ namespace WixToolset.Extensions /// Parses a WixStandardBootstrapperApplication element for Bundles. /// /// The element to parse. - private void ParseWixStandardBootstrapperApplicationElement(XElement node) + private void ParseWixStandardBootstrapperApplicationElement(Intermediate intermediate, IntermediateSection section, XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); string launchTarget = null; string launchTargetElevatedId = null; string launchArguments = null; @@ -314,101 +318,101 @@ namespace WixToolset.Extensions switch (attrib.Name.LocalName) { case "LaunchTarget": - launchTarget = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + launchTarget = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "LaunchTargetElevatedId": - launchTargetElevatedId = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + launchTargetElevatedId = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); break; case "LaunchArguments": - launchArguments = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + launchArguments = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "LaunchHidden": - launchHidden = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + launchHidden = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib); break; case "LaunchWorkingFolder": - launchWorkingDir = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + launchWorkingDir = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "LicenseFile": - licenseFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + licenseFile = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "LicenseUrl": - licenseUrl = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); + licenseUrl = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); break; case "LogoFile": - logoFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + logoFile = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "LogoSideFile": - logoSideFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + logoSideFile = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "ThemeFile": - themeFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + themeFile = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "LocalizationFile": - localizationFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + localizationFile = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "SuppressOptionsUI": - suppressOptionsUI = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + suppressOptionsUI = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib); break; case "SuppressDowngradeFailure": - suppressDowngradeFailure = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + suppressDowngradeFailure = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib); break; case "SuppressRepair": - suppressRepair = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + suppressRepair = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib); break; case "ShowVersion": - showVersion = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + showVersion = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib); break; case "SupportCacheOnly": - supportCacheOnly = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + supportCacheOnly = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib); break; default: - this.Core.UnexpectedAttribute(node, attrib); + this.ParseHelper.UnexpectedAttribute(node, attrib); break; } } else { - this.Core.ParseExtensionAttribute(node, attrib); + this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); } } - this.Core.ParseForExtensionElements(node); + this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); if (String.IsNullOrEmpty(licenseFile) && null == licenseUrl) { - this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "LicenseFile", "LicenseUrl", true)); + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "LicenseFile", "LicenseUrl", true)); } - if (!this.Core.EncounteredError) + if (!this.Messaging.EncounteredError) { if (!String.IsNullOrEmpty(launchTarget)) { - WixBundleVariableRow row = (WixBundleVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixBundleVariable"); - row.Id = "LaunchTarget"; + var row = (WixBundleVariableTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixBundleVariable"); + row.Id = new Identifier("LaunchTarget", AccessModifier.Public); row.Value = launchTarget; row.Type = "string"; } if (!String.IsNullOrEmpty(launchTargetElevatedId)) { - WixBundleVariableRow row = (WixBundleVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixBundleVariable"); - row.Id = "LaunchTargetElevatedId"; + var row = (WixBundleVariableTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixBundleVariable"); + row.Id = new Identifier("LaunchTargetElevatedId", AccessModifier.Public); row.Value = launchTargetElevatedId; row.Type = "string"; } if (!String.IsNullOrEmpty(launchArguments)) { - WixBundleVariableRow row = (WixBundleVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixBundleVariable"); - row.Id = "LaunchArguments"; + var row = (WixBundleVariableTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixBundleVariable"); + row.Id = new Identifier("LaunchArguments", AccessModifier.Public); row.Value = launchArguments; row.Type = "string"; } if (YesNoType.Yes == launchHidden) { - WixBundleVariableRow row = (WixBundleVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixBundleVariable"); - row.Id = "LaunchHidden"; + var row = (WixBundleVariableTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixBundleVariable"); + row.Id = new Identifier("LaunchHidden", AccessModifier.Public); row.Value = "yes"; row.Type = "string"; } @@ -416,80 +420,80 @@ namespace WixToolset.Extensions if (!String.IsNullOrEmpty(launchWorkingDir)) { - WixBundleVariableRow row = (WixBundleVariableRow)this.Core.CreateRow(sourceLineNumbers, "Variable"); - row.Id = "LaunchWorkingFolder"; + var row = (WixBundleVariableTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "Variable"); + row.Id = new Identifier("LaunchWorkingFolder", AccessModifier.Public); row.Value = launchWorkingDir; row.Type = "string"; } if (!String.IsNullOrEmpty(licenseFile)) { - WixVariableRow wixVariableRow = (WixVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixVariable"); - wixVariableRow.Id = "WixStdbaLicenseRtf"; + var wixVariableRow = (WixVariableTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixVariable"); + wixVariableRow.Id = new Identifier("WixStdbaLicenseRtf", AccessModifier.Public); wixVariableRow.Value = licenseFile; } if (null != licenseUrl) { - WixVariableRow wixVariableRow = (WixVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixVariable"); - wixVariableRow.Id = "WixStdbaLicenseUrl"; + var wixVariableRow = (WixVariableTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixVariable"); + wixVariableRow.Id = new Identifier("WixStdbaLicenseUrl", AccessModifier.Public); wixVariableRow.Value = licenseUrl; } if (!String.IsNullOrEmpty(logoFile)) { - WixVariableRow wixVariableRow = (WixVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixVariable"); - wixVariableRow.Id = "WixStdbaLogo"; + var wixVariableRow = (WixVariableTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixVariable"); + wixVariableRow.Id = new Identifier("WixStdbaLogo", AccessModifier.Public); wixVariableRow.Value = logoFile; } if (!String.IsNullOrEmpty(logoSideFile)) { - WixVariableRow wixVariableRow = (WixVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixVariable"); - wixVariableRow.Id = "WixStdbaLogoSide"; + var wixVariableRow = (WixVariableTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixVariable"); + wixVariableRow.Id = new Identifier("WixStdbaLogoSide", AccessModifier.Public); wixVariableRow.Value = logoSideFile; } if (!String.IsNullOrEmpty(themeFile)) { - WixVariableRow wixVariableRow = (WixVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixVariable"); - wixVariableRow.Id = "WixStdbaThemeXml"; + var wixVariableRow = (WixVariableTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixVariable"); + wixVariableRow.Id = new Identifier("WixStdbaThemeXml", AccessModifier.Public); wixVariableRow.Value = themeFile; } if (!String.IsNullOrEmpty(localizationFile)) { - WixVariableRow wixVariableRow = (WixVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixVariable"); - wixVariableRow.Id = "WixStdbaThemeWxl"; + var wixVariableRow = (WixVariableTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixVariable"); + wixVariableRow.Id = new Identifier("WixStdbaThemeWxl", AccessModifier.Public); wixVariableRow.Value = localizationFile; } if (YesNoType.Yes == suppressOptionsUI || YesNoType.Yes == suppressDowngradeFailure || YesNoType.Yes == suppressRepair || YesNoType.Yes == showVersion || YesNoType.Yes == supportCacheOnly) { - Row row = this.Core.CreateRow(sourceLineNumbers, "WixStdbaOptions"); + var tuple = (WixStdbaOptionsTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixStdbaOptions"); if (YesNoType.Yes == suppressOptionsUI) { - row[0] = 1; + tuple.SuppressOptionsUI = 1; } if (YesNoType.Yes == suppressDowngradeFailure) { - row[1] = 1; + tuple.SuppressDowngradeFailure = 1; } if (YesNoType.Yes == suppressRepair) { - row[2] = 1; + tuple.SuppressRepair = 1; } if (YesNoType.Yes == showVersion) { - row[3] = 1; + tuple.ShowVersion = 1; } if (YesNoType.Yes == supportCacheOnly) { - row[4] = 1; + tuple.SupportCacheOnly = 1; } } } @@ -499,9 +503,9 @@ namespace WixToolset.Extensions /// Parses a WixManagedBootstrapperApplicationHost element for Bundles. /// /// The element to parse. - private void ParseWixManagedBootstrapperApplicationHostElement(XElement node) + private void ParseWixManagedBootstrapperApplicationHostElement(Intermediate intermediate, IntermediateSection section, XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); string logoFile = null; string themeFile = null; string localizationFile = null; @@ -513,47 +517,47 @@ namespace WixToolset.Extensions switch (attrib.Name.LocalName) { case "LogoFile": - logoFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + logoFile = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "ThemeFile": - themeFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + themeFile = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "LocalizationFile": - localizationFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + localizationFile = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; default: - this.Core.UnexpectedAttribute(node, attrib); + this.ParseHelper.UnexpectedAttribute(node, attrib); break; } } else { - this.Core.ParseExtensionAttribute(node, attrib); + this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); } } - this.Core.ParseForExtensionElements(node); + this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); - if (!this.Core.EncounteredError) + if (!this.Messaging.EncounteredError) { if (!String.IsNullOrEmpty(logoFile)) { - WixVariableRow wixVariableRow = (WixVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixVariable"); - wixVariableRow.Id = "PreqbaLogo"; + var wixVariableRow = (WixVariableTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixVariable"); + wixVariableRow.Id = new Identifier("PreqbaLogo", AccessModifier.Public); wixVariableRow.Value = logoFile; } if (!String.IsNullOrEmpty(themeFile)) { - WixVariableRow wixVariableRow = (WixVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixVariable"); - wixVariableRow.Id = "PreqbaThemeXml"; + var wixVariableRow = (WixVariableTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixVariable"); + wixVariableRow.Id = new Identifier("PreqbaThemeXml", AccessModifier.Public); wixVariableRow.Value = themeFile; } if (!String.IsNullOrEmpty(localizationFile)) { - WixVariableRow wixVariableRow = (WixVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixVariable"); - wixVariableRow.Id = "PreqbaThemeWxl"; + var wixVariableRow = (WixVariableTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixVariable"); + wixVariableRow.Id = new Identifier("PreqbaThemeWxl", AccessModifier.Public); wixVariableRow.Value = localizationFile; } } diff --git a/src/wixext/BalErrors.cs b/src/wixext/BalErrors.cs new file mode 100644 index 00000000..5591ae1d --- /dev/null +++ b/src/wixext/BalErrors.cs @@ -0,0 +1,55 @@ +// 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.Resources; + using WixToolset.Data; + + public static class BalErrors + { + public static Message AttributeRequiresPrereqPackage(SourceLineNumber sourceLineNumbers, string elementName, string attributeName) + { + return Message(sourceLineNumbers, Ids.AttributeRequiresPrereqPackage, "When the {0}/@{1} attribute is specified, the {0}/@PrereqPackage attribute must be set to \"yes\".", elementName, attributeName); + } + + public static Message BAFunctionsPayloadRequiredInUXContainer(SourceLineNumber sourceLineNumbers) + { + return Message(sourceLineNumbers, Ids.BAFunctionsPayloadRequiredInUXContainer, "The BAFunctions DLL Payload element must be located inside the BootstrapperApplication container."); + } + + public static Message MissingPrereq() + { + return Message(null, Ids.MissingPrereq, "There must be at least one PrereqPackage when using the ManagedBootstrapperApplicationHost.\nThis is typically done by using the WixNetFxExtension and referencing one of the NetFxAsPrereq package groups."); + } + + public static Message MultipleBAFunctions(SourceLineNumber sourceLineNumbers) + { + return Message(sourceLineNumbers, Ids.MultipleBAFunctions, "WixStandardBootstrapperApplication doesn't support multiple BAFunctions DLLs."); + } + + public static Message MultiplePrereqLicenses(SourceLineNumber sourceLineNumbers) + { + return Message(sourceLineNumbers, Ids.MultiplePrereqLicenses, "There may only be one package in the bundle that has either the PrereqLicenseFile attribute or the PrereqLicenseUrl attribute."); + } + + private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args) + { + return new Message(sourceLineNumber, MessageLevel.Error, (int)id, format, args); + } + + private static Message Message(SourceLineNumber sourceLineNumber, Ids id, ResourceManager resourceManager, string resourceName, params object[] args) + { + return new Message(sourceLineNumber, MessageLevel.Error, (int)id, resourceManager, resourceName, args); + } + + public enum Ids + { + AttributeRequiresPrereqPackage = 6801, + MissingPrereq = 6802, + MultiplePrereqLicenses = 6803, + MultipleBAFunctions = 6804, + BAFunctionsPayloadRequiredInUXContainer = 6805, + } + } +} diff --git a/src/wixext/BalExtensionData.cs b/src/wixext/BalExtensionData.cs index 7e8dea5b..46152b53 100644 --- a/src/wixext/BalExtensionData.cs +++ b/src/wixext/BalExtensionData.cs @@ -1,55 +1,30 @@ // 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.Extensions +namespace WixToolset.Bal { - using System; - using System.Reflection; using WixToolset.Data; using WixToolset.Extensibility; /// /// The WiX Toolset Bal Extension. /// - public sealed class BalExtensionData : ExtensionData + public sealed class BalExtensionData : BaseExtensionData { /// - /// Gets the optional table definitions for this extension. + /// Gets the default culture. /// - /// The optional table definitions for this extension. - public override TableDefinitionCollection TableDefinitions - { - get - { - return BalExtensionData.GetExtensionTableDefinitions(); - } - } + /// The default culture. + public override string DefaultCulture => "en-US"; - /// - /// Gets the library associated with this extension. - /// - /// The table definitions to use while loading the library. - /// The loaded library. - public override Library GetLibrary(TableDefinitionCollection tableDefinitions) + public override bool TryGetTupleDefinitionByName(string name, out IntermediateTupleDefinition tupleDefinition) { - return BalExtensionData.GetExtensionLibrary(tableDefinitions); + tupleDefinition = BalTupleDefinitions.ByName(name); + return tupleDefinition != null; } - /// - /// Internal mechanism to access the extension's table definitions. - /// - /// Extension's table definitions. - internal static TableDefinitionCollection GetExtensionTableDefinitions() - { - return ExtensionData.LoadTableDefinitionHelper(Assembly.GetExecutingAssembly(), "WixToolset.Extensions.Data.tables.xml"); - } - - /// - /// Internal mechanism to access the extension's library. - /// - /// Extension's library. - internal static Library GetExtensionLibrary(TableDefinitionCollection tableDefinitions) + public override Intermediate GetLibrary(ITupleDefinitionCreator tupleDefinitions) { - return ExtensionData.LoadLibraryHelper(Assembly.GetExecutingAssembly(), "WixToolset.Extensions.Data.bal.wixlib", tableDefinitions); + return Intermediate.Load(typeof(BalExtensionData).Assembly, "WixToolset.Bal.bal.wixlib", tupleDefinitions); } } } diff --git a/src/wixext/BalExtensionFactory.cs b/src/wixext/BalExtensionFactory.cs new file mode 100644 index 00000000..936686a6 --- /dev/null +++ b/src/wixext/BalExtensionFactory.cs @@ -0,0 +1,18 @@ +// 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 WixToolset.Extensibility; + + public class BalExtensionFactory : BaseExtensionFactory + { + protected override IEnumerable ExtensionTypes => new[] + { + typeof(BalCompiler), + typeof(BalExtensionData), + typeof(BalWindowsInstallerBackendBinderExtension), + }; + } +} diff --git a/src/wixext/BalWarnings.cs b/src/wixext/BalWarnings.cs new file mode 100644 index 00000000..18b25062 --- /dev/null +++ b/src/wixext/BalWarnings.cs @@ -0,0 +1,31 @@ +// 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.Resources; + using WixToolset.Data; + + public static class BalWarnings + { + public static Message UnmarkedBAFunctionsDLL(SourceLineNumber sourceLineNumbers) + { + return Message(sourceLineNumbers, Ids.UnmarkedBAFunctionsDLL, "WixStandardBootstrapperApplication doesn't automatically load BAFunctions.dll. Use the bal:BAFunctions attribute to indicate that it should be loaded."); + } + + private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args) + { + return new Message(sourceLineNumber, MessageLevel.Warning, (int)id, format, args); + } + + private static Message Message(SourceLineNumber sourceLineNumber, Ids id, ResourceManager resourceManager, string resourceName, params object[] args) + { + return new Message(sourceLineNumber, MessageLevel.Warning, (int)id, resourceManager, resourceName, args); + } + + public enum Ids + { + UnmarkedBAFunctionsDLL = 6501, + } + } +} diff --git a/src/wixext/BalWindowsInstallerBackendBinderExtension.cs b/src/wixext/BalWindowsInstallerBackendBinderExtension.cs new file mode 100644 index 00000000..fbda9d1b --- /dev/null +++ b/src/wixext/BalWindowsInstallerBackendBinderExtension.cs @@ -0,0 +1,146 @@ +// 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 System.Xml; + using WixToolset.Data; + using WixToolset.Data.WindowsInstaller; + using WixToolset.Data.WindowsInstaller.Rows; + using WixToolset.Extensibility; + using WixToolset.Extensibility.Data; + + public class BalWindowsInstallerBackendBinderExtension : BaseWindowsInstallerBackendBinderExtension + { + // TODO: don't duplicate this from WixToolset.Core.Compiler + public const string BurnUXContainerId = "WixUXContainer"; + + private static readonly TableDefinition[] Tables = LoadTables(); + + protected override TableDefinition[] TableDefinitionsForTuples => 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(BindResult result, Pdb pdb) + { + base.PostBackendBind(result, pdb); + + var output = pdb.Output; + + // 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(Output 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 (BurnUXContainerId != bundlePayloadRow.Container) + { + this.Messaging.Write(BalErrors.BAFunctionsPayloadRequiredInUXContainer(baFunctionsRow.SourceLineNumbers)); + } + } + } + + private void VerifyPrereqPackages(Output 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/Tuples/BalTupleDefinitions.cs b/src/wixext/Tuples/BalTupleDefinitions.cs new file mode 100644 index 00000000..676db9f6 --- /dev/null +++ b/src/wixext/Tuples/BalTupleDefinitions.cs @@ -0,0 +1,55 @@ +// 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 WixToolset.Data; + + public enum BalTupleDefinitionType + { + WixBalBAFunctions, + WixBalCondition, + WixMbaPrereqInformation, + WixStdbaOptions, + WixStdbaOverridableVariable, + } + + public static partial class BalTupleDefinitions + { + public static readonly Version Version = new Version("4.0.0"); + + public static IntermediateTupleDefinition ByName(string name) + { + if (!Enum.TryParse(name, out BalTupleDefinitionType type)) + { + return null; + } + + return ByType(type); + } + + public static IntermediateTupleDefinition ByType(BalTupleDefinitionType type) + { + switch (type) + { + case BalTupleDefinitionType.WixBalBAFunctions: + return BalTupleDefinitions.WixBalBAFunctions; + + case BalTupleDefinitionType.WixBalCondition: + return BalTupleDefinitions.WixBalCondition; + + case BalTupleDefinitionType.WixMbaPrereqInformation: + return BalTupleDefinitions.WixMbaPrereqInformation; + + case BalTupleDefinitionType.WixStdbaOptions: + return BalTupleDefinitions.WixStdbaOptions; + + case BalTupleDefinitionType.WixStdbaOverridableVariable: + return BalTupleDefinitions.WixStdbaOverridableVariable; + + default: + throw new ArgumentOutOfRangeException(nameof(type)); + } + } + } +} diff --git a/src/wixext/Tuples/WixBalBAFunctionsTuple.cs b/src/wixext/Tuples/WixBalBAFunctionsTuple.cs new file mode 100644 index 00000000..f753f239 --- /dev/null +++ b/src/wixext/Tuples/WixBalBAFunctionsTuple.cs @@ -0,0 +1,47 @@ +// 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 WixToolset.Data; + using WixToolset.Bal.Tuples; + + public static partial class BalTupleDefinitions + { + public static readonly IntermediateTupleDefinition WixBalBAFunctions = new IntermediateTupleDefinition( + BalTupleDefinitionType.WixBalBAFunctions.ToString(), + new[] + { + new IntermediateFieldDefinition(nameof(WixBalBAFunctionsTupleFields.PayloadId), IntermediateFieldType.String), + }, + typeof(WixBalBAFunctionsTuple)); + } +} + +namespace WixToolset.Bal.Tuples +{ + using WixToolset.Data; + + public enum WixBalBAFunctionsTupleFields + { + PayloadId, + } + + public class WixBalBAFunctionsTuple : IntermediateTuple + { + public WixBalBAFunctionsTuple() : base(BalTupleDefinitions.WixBalBAFunctions, null, null) + { + } + + public WixBalBAFunctionsTuple(SourceLineNumber sourceLineNumber, Identifier id = null) : base(BalTupleDefinitions.WixBalBAFunctions, sourceLineNumber, id) + { + } + + public IntermediateField this[WixBalBAFunctionsTupleFields index] => this.Fields[(int)index]; + + public string PayloadId + { + get => this.Fields[(int)WixBalBAFunctionsTupleFields.PayloadId].AsString(); + set => this.Set((int)WixBalBAFunctionsTupleFields.PayloadId, value); + } + } +} \ No newline at end of file diff --git a/src/wixext/Tuples/WixBalConditionTuple.cs b/src/wixext/Tuples/WixBalConditionTuple.cs new file mode 100644 index 00000000..4c0ddd1d --- /dev/null +++ b/src/wixext/Tuples/WixBalConditionTuple.cs @@ -0,0 +1,55 @@ +// 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 WixToolset.Data; + using WixToolset.Bal.Tuples; + + public static partial class BalTupleDefinitions + { + public static readonly IntermediateTupleDefinition WixBalCondition = new IntermediateTupleDefinition( + BalTupleDefinitionType.WixBalCondition.ToString(), + new[] + { + new IntermediateFieldDefinition(nameof(WixBalConditionTupleFields.Condition), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixBalConditionTupleFields.Message), IntermediateFieldType.String), + }, + typeof(WixBalConditionTuple)); + } +} + +namespace WixToolset.Bal.Tuples +{ + using WixToolset.Data; + + public enum WixBalConditionTupleFields + { + Condition, + Message, + } + + public class WixBalConditionTuple : IntermediateTuple + { + public WixBalConditionTuple() : base(BalTupleDefinitions.WixBalCondition, null, null) + { + } + + public WixBalConditionTuple(SourceLineNumber sourceLineNumber, Identifier id = null) : base(BalTupleDefinitions.WixBalCondition, sourceLineNumber, id) + { + } + + public IntermediateField this[WixBalConditionTupleFields index] => this.Fields[(int)index]; + + public string Condition + { + get => this.Fields[(int)WixBalConditionTupleFields.Condition].AsString(); + set => this.Set((int)WixBalConditionTupleFields.Condition, value); + } + + public string Message + { + get => this.Fields[(int)WixBalConditionTupleFields.Message].AsString(); + set => this.Set((int)WixBalConditionTupleFields.Message, value); + } + } +} \ No newline at end of file diff --git a/src/wixext/Tuples/WixMbaPrereqInformationTuple.cs b/src/wixext/Tuples/WixMbaPrereqInformationTuple.cs new file mode 100644 index 00000000..bcbe9f84 --- /dev/null +++ b/src/wixext/Tuples/WixMbaPrereqInformationTuple.cs @@ -0,0 +1,63 @@ +// 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 WixToolset.Data; + using WixToolset.Bal.Tuples; + + public static partial class BalTupleDefinitions + { + public static readonly IntermediateTupleDefinition WixMbaPrereqInformation = new IntermediateTupleDefinition( + BalTupleDefinitionType.WixMbaPrereqInformation.ToString(), + new[] + { + new IntermediateFieldDefinition(nameof(WixMbaPrereqInformationTupleFields.PackageId), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixMbaPrereqInformationTupleFields.LicenseFile), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixMbaPrereqInformationTupleFields.LicenseUrl), IntermediateFieldType.String), + }, + typeof(WixMbaPrereqInformationTuple)); + } +} + +namespace WixToolset.Bal.Tuples +{ + using WixToolset.Data; + + public enum WixMbaPrereqInformationTupleFields + { + PackageId, + LicenseFile, + LicenseUrl, + } + + public class WixMbaPrereqInformationTuple : IntermediateTuple + { + public WixMbaPrereqInformationTuple() : base(BalTupleDefinitions.WixMbaPrereqInformation, null, null) + { + } + + public WixMbaPrereqInformationTuple(SourceLineNumber sourceLineNumber, Identifier id = null) : base(BalTupleDefinitions.WixMbaPrereqInformation, sourceLineNumber, id) + { + } + + public IntermediateField this[WixMbaPrereqInformationTupleFields index] => this.Fields[(int)index]; + + public string PackageId + { + get => this.Fields[(int)WixMbaPrereqInformationTupleFields.PackageId].AsString(); + set => this.Set((int)WixMbaPrereqInformationTupleFields.PackageId, value); + } + + public string LicenseFile + { + get => this.Fields[(int)WixMbaPrereqInformationTupleFields.LicenseFile].AsString(); + set => this.Set((int)WixMbaPrereqInformationTupleFields.LicenseFile, value); + } + + public string LicenseUrl + { + get => this.Fields[(int)WixMbaPrereqInformationTupleFields.LicenseUrl].AsString(); + set => this.Set((int)WixMbaPrereqInformationTupleFields.LicenseUrl, value); + } + } +} \ No newline at end of file diff --git a/src/wixext/Tuples/WixStdbaOptionsTuple.cs b/src/wixext/Tuples/WixStdbaOptionsTuple.cs new file mode 100644 index 00000000..d930eb47 --- /dev/null +++ b/src/wixext/Tuples/WixStdbaOptionsTuple.cs @@ -0,0 +1,79 @@ +// 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 WixToolset.Data; + using WixToolset.Bal.Tuples; + + public static partial class BalTupleDefinitions + { + public static readonly IntermediateTupleDefinition WixStdbaOptions = new IntermediateTupleDefinition( + BalTupleDefinitionType.WixStdbaOptions.ToString(), + new[] + { + new IntermediateFieldDefinition(nameof(WixStdbaOptionsTupleFields.SuppressOptionsUI), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(WixStdbaOptionsTupleFields.SuppressDowngradeFailure), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(WixStdbaOptionsTupleFields.SuppressRepair), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(WixStdbaOptionsTupleFields.ShowVersion), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(WixStdbaOptionsTupleFields.SupportCacheOnly), IntermediateFieldType.Number), + }, + typeof(WixStdbaOptionsTuple)); + } +} + +namespace WixToolset.Bal.Tuples +{ + using WixToolset.Data; + + public enum WixStdbaOptionsTupleFields + { + SuppressOptionsUI, + SuppressDowngradeFailure, + SuppressRepair, + ShowVersion, + SupportCacheOnly, + } + + public class WixStdbaOptionsTuple : IntermediateTuple + { + public WixStdbaOptionsTuple() : base(BalTupleDefinitions.WixStdbaOptions, null, null) + { + } + + public WixStdbaOptionsTuple(SourceLineNumber sourceLineNumber, Identifier id = null) : base(BalTupleDefinitions.WixStdbaOptions, sourceLineNumber, id) + { + } + + public IntermediateField this[WixStdbaOptionsTupleFields index] => this.Fields[(int)index]; + + public int SuppressOptionsUI + { + get => this.Fields[(int)WixStdbaOptionsTupleFields.SuppressOptionsUI].AsNumber(); + set => this.Set((int)WixStdbaOptionsTupleFields.SuppressOptionsUI, value); + } + + public int SuppressDowngradeFailure + { + get => this.Fields[(int)WixStdbaOptionsTupleFields.SuppressDowngradeFailure].AsNumber(); + set => this.Set((int)WixStdbaOptionsTupleFields.SuppressDowngradeFailure, value); + } + + public int SuppressRepair + { + get => this.Fields[(int)WixStdbaOptionsTupleFields.SuppressRepair].AsNumber(); + set => this.Set((int)WixStdbaOptionsTupleFields.SuppressRepair, value); + } + + public int ShowVersion + { + get => this.Fields[(int)WixStdbaOptionsTupleFields.ShowVersion].AsNumber(); + set => this.Set((int)WixStdbaOptionsTupleFields.ShowVersion, value); + } + + public int SupportCacheOnly + { + get => this.Fields[(int)WixStdbaOptionsTupleFields.SupportCacheOnly].AsNumber(); + set => this.Set((int)WixStdbaOptionsTupleFields.SupportCacheOnly, value); + } + } +} \ No newline at end of file diff --git a/src/wixext/Tuples/WixStdbaOverridableVariableTuple.cs b/src/wixext/Tuples/WixStdbaOverridableVariableTuple.cs new file mode 100644 index 00000000..3ba982ea --- /dev/null +++ b/src/wixext/Tuples/WixStdbaOverridableVariableTuple.cs @@ -0,0 +1,47 @@ +// 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 WixToolset.Data; + using WixToolset.Bal.Tuples; + + public static partial class BalTupleDefinitions + { + public static readonly IntermediateTupleDefinition WixStdbaOverridableVariable = new IntermediateTupleDefinition( + BalTupleDefinitionType.WixStdbaOverridableVariable.ToString(), + new[] + { + new IntermediateFieldDefinition(nameof(WixStdbaOverridableVariableTupleFields.Name), IntermediateFieldType.String), + }, + typeof(WixStdbaOverridableVariableTuple)); + } +} + +namespace WixToolset.Bal.Tuples +{ + using WixToolset.Data; + + public enum WixStdbaOverridableVariableTupleFields + { + Name, + } + + public class WixStdbaOverridableVariableTuple : IntermediateTuple + { + public WixStdbaOverridableVariableTuple() : base(BalTupleDefinitions.WixStdbaOverridableVariable, null, null) + { + } + + public WixStdbaOverridableVariableTuple(SourceLineNumber sourceLineNumber, Identifier id = null) : base(BalTupleDefinitions.WixStdbaOverridableVariable, sourceLineNumber, id) + { + } + + public IntermediateField this[WixStdbaOverridableVariableTupleFields index] => this.Fields[(int)index]; + + public string Name + { + get => this.Fields[(int)WixStdbaOverridableVariableTupleFields.Name].AsString(); + set => this.Set((int)WixStdbaOverridableVariableTupleFields.Name, value); + } + } +} \ No newline at end of file diff --git a/src/wixext/WixBalExtension.csproj b/src/wixext/WixBalExtension.csproj deleted file mode 100644 index 3e9d382e..00000000 --- a/src/wixext/WixBalExtension.csproj +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - {BF720A63-9D7B-456E-B60C-8122852D9FED} - WixBalExtension - Library - WixToolset.Extensions - - - - - - - - $(RootNamespace).Data.Messages.resources - - - $(RootNamespace).Data.tables.xml - - - $(RootNamespace).Xsd.bal.xsd - PreserveNewest - - - WixToolset.Data.Serialize - WixToolset.Extensions.Serialize.Bal - - - Data\bal.wixlib - - - - - - - - - - - false - - - - diff --git a/src/wixext/WixToolset.Bal.wixext.csproj b/src/wixext/WixToolset.Bal.wixext.csproj new file mode 100644 index 00000000..49f891d3 --- /dev/null +++ b/src/wixext/WixToolset.Bal.wixext.csproj @@ -0,0 +1,30 @@ + + + + + + netstandard2.0 + WixToolset.Bal + WiX Toolset Bal Extension + WiX Toolset Bal Extension + true + build + + + + + + + + + + + + + + + + + + + diff --git a/src/wixext/WixToolset.Bal.wixext.targets b/src/wixext/WixToolset.Bal.wixext.targets new file mode 100644 index 00000000..70c5a19c --- /dev/null +++ b/src/wixext/WixToolset.Bal.wixext.targets @@ -0,0 +1,11 @@ + + + + + + $(MSBuildThisFileDirectory)..\tools\WixToolset.Bal.wixext.dll + + + + + diff --git a/src/wixext/messages.xml b/src/wixext/messages.xml deleted file mode 100644 index 9b11981d..00000000 --- a/src/wixext/messages.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - When the {0}/@{1} attribute is specified, the {0}/@PrereqPackage attribute must be set to "yes". - - - - - - - There must be at least one PrereqPackage when using the ManagedBootstrapperApplicationHost. - This is typically done by using the WixNetFxExtension and referencing one of the NetFxAsPrereq package groups. - - - - - There may only be one package in the bundle that has either the PrereqLicenseFile attribute or the PrereqLicenseUrl attribute. - - - - - WixStandardBootstrapperApplication doesn't support multiple BAFunctions DLLs. - - - - - The BAFunctions DLL Payload element must be located inside the BootstrapperApplication container. - - - - - - - WixStandardBootstrapperApplication doesn't automatically load BAFunctions.dll. Use the bal:BAFunctions attribute to indicate that it should be loaded. - - - - -- cgit v1.2.3-55-g6feb