private void VerifyBAFunctions(Output output) { Row baFunctionsRow = null; Table baFunctionsTable = output.Tables["WixBalBAFunctions"]; foreach (Row row in baFunctionsTable.RowsAs <Row>()) { if (null == baFunctionsRow) { baFunctionsRow = row; } else { this.Core.OnMessage(BalErrors.MultipleBAFunctions(row.SourceLineNumbers)); } } Table payloadPropertiesTable = output.Tables["WixPayloadProperties"]; IEnumerable <WixPayloadPropertiesRow> payloadPropertiesRows = payloadPropertiesTable.RowsAs <WixPayloadPropertiesRow>(); 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; } } }
/// <summary> /// Processes an attribute for the Compiler. /// </summary> /// <param name="sourceLineNumbers">Source line number for the parent element.</param> /// <param name="parentElement">Parent element of element to process.</param> /// <param name="attribute">Attribute to process.</param> /// <param name="context">Extra information about the context in which this element is being parsed.</param> public override void ParseAttribute(XElement parentElement, XAttribute attribute, IDictionary <string, string> context) { SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(parentElement); Row row; switch (parentElement.Name.LocalName) { case "ExePackage": case "MsiPackage": case "MspPackage": case "MsuPackage": string packageId; if (!context.TryGetValue("PackageId", out packageId) || String.IsNullOrEmpty(packageId)) { this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, parentElement.Name.LocalName, "Id", attribute.Name.LocalName)); } else { switch (attribute.Name.LocalName) { case "PrereqLicenseFile": if (!prereqInfoRows.TryGetValue(packageId, out row)) { // 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)) { row = this.Core.CreateRow(sourceLineNumbers, "WixMbaPrereqInformation"); row[0] = packageId; prereqInfoRows.Add(packageId, row); } else { this.Core.OnMessage(BalErrors.AttributeRequiresPrereqPackage(sourceLineNumbers, parentElement.Name.LocalName, "PrereqLicenseFile")); break; } } if (null != row[2]) { this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttribute(sourceLineNumbers, parentElement.Name.LocalName, "PrereqLicenseFile", "PrereqLicenseUrl")); } else { row[1] = this.Core.GetAttributeValue(sourceLineNumbers, attribute); } break; case "PrereqLicenseUrl": if (!prereqInfoRows.TryGetValue(packageId, out row)) { // 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)) { row = this.Core.CreateRow(sourceLineNumbers, "WixMbaPrereqInformation"); row[0] = packageId; prereqInfoRows.Add(packageId, row); } else { this.Core.OnMessage(BalErrors.AttributeRequiresPrereqPackage(sourceLineNumbers, parentElement.Name.LocalName, "PrereqLicenseUrl")); break; } } if (null != row[1]) { this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttribute(sourceLineNumbers, parentElement.Name.LocalName, "PrereqLicenseUrl", "PrereqLicenseFile")); } else { row[2] = this.Core.GetAttributeValue(sourceLineNumbers, attribute); } break; case "PrereqPackage": if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attribute)) { if (!prereqInfoRows.TryGetValue(packageId, out row)) { row = this.Core.CreateRow(sourceLineNumbers, "WixMbaPrereqInformation"); row[0] = packageId; prereqInfoRows.Add(packageId, row); } } break; default: this.Core.UnexpectedAttribute(parentElement, attribute); break; } } break; case "Payload": string payloadId; if (!context.TryGetValue("Id", out payloadId) || String.IsNullOrEmpty(payloadId)) { this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, parentElement.Name.LocalName, "Id", attribute.Name.LocalName)); } else { switch (attribute.Name.LocalName) { case "BAFunctions": if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attribute)) { row = this.Core.CreateRow(sourceLineNumbers, "WixBalBAFunctions"); row[0] = payloadId; } break; default: this.Core.UnexpectedAttribute(parentElement, attribute); break; } } break; case "Variable": // at the time the extension attribute is parsed, the compiler might not yet have // parsed the Name attribute, so we need to get it directly from the parent element. XAttribute variableName = parentElement.Attribute("Name"); if (null == variableName) { this.Core.OnMessage(WixErrors.ExpectedParentWithAttribute(sourceLineNumbers, "Variable", "Overridable", "Name")); } else { switch (attribute.Name.LocalName) { case "Overridable": if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attribute)) { row = this.Core.CreateRow(sourceLineNumbers, "WixStdbaOverridableVariable"); row[0] = variableName; } break; default: this.Core.UnexpectedAttribute(parentElement, attribute); break; } } break; } }