/// <summary> /// Parses a Tag element for Software Id Tag registration under a Bundle element. /// </summary> /// <param name="node">The element to parse.</param> private void ParseBundleTagElement(XmlNode node) { SourceLineNumberCollection sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string name = null; string regid = null; YesNoType licensed = YesNoType.NotSet; string type = null; foreach (XmlAttribute attrib in node.Attributes) { if (0 == attrib.NamespaceURI.Length || attrib.NamespaceURI == this.schema.TargetNamespace) { switch (attrib.LocalName) { case "Name": name = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false); break; case "Regid": regid = this.Core.GetAttributeValue(sourceLineNumbers, attrib); break; case "Licensed": licensed = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); break; case "Type": type = this.ParseTagTypeAttribute(sourceLineNumbers, node, attrib); break; default: this.Core.UnexpectedAttribute(sourceLineNumbers, attrib); break; } } else { this.Core.UnsupportedExtensionAttribute(sourceLineNumbers, attrib); } } foreach (XmlNode child in node.ChildNodes) { if (XmlNodeType.Element == child.NodeType) { if (child.NamespaceURI == this.Schema.TargetNamespace) { this.Core.UnexpectedElement(node, child); } else { this.Core.UnsupportedExtensionElement(node, child); } } } if (String.IsNullOrEmpty(name)) { XmlAttribute productNameAttribute = node.ParentNode.Attributes["Name"]; if (null != productNameAttribute) { name = productNameAttribute.Value; } else { this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name, "Name")); } } if (!String.IsNullOrEmpty(name) && !CompilerCore.IsValidLongFilename(name, false)) { this.Core.OnMessage(TagErrors.IllegalName(sourceLineNumbers, node.ParentNode.LocalName, name)); } if (String.IsNullOrEmpty(regid)) { this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name, "Regid")); } if (!this.Core.EncounteredError) { string fileName = String.Concat(regid, " ", name, ".swidtag"); Row tagRow = this.Core.CreateRow(sourceLineNumbers, "WixBundleTag"); tagRow[0] = fileName; tagRow[1] = regid; tagRow[2] = name; if (YesNoType.Yes == licensed) { tagRow[3] = 1; } // field 4 is the TagXml set by the binder. tagRow[5] = type; } }
/// <summary> /// Parses a Tag element for Software Id Tag registration under a Product element. /// </summary> /// <param name="node">The element to parse.</param> private void ParseProductTagElement(XmlNode node) { SourceLineNumberCollection sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string name = null; string regid = null; string feature = "WixSwidTag"; YesNoType licensed = YesNoType.NotSet; string type = null;; foreach (XmlAttribute attrib in node.Attributes) { if (0 == attrib.NamespaceURI.Length || attrib.NamespaceURI == this.schema.TargetNamespace) { switch (attrib.LocalName) { case "Name": name = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false); break; case "Regid": regid = this.Core.GetAttributeValue(sourceLineNumbers, attrib); break; case "Feature": feature = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); break; case "Licensed": licensed = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); break; case "Type": type = this.ParseTagTypeAttribute(sourceLineNumbers, node, attrib); break; default: this.Core.UnexpectedAttribute(sourceLineNumbers, attrib); break; } } else { this.Core.UnsupportedExtensionAttribute(sourceLineNumbers, attrib); } } foreach (XmlNode child in node.ChildNodes) { if (XmlNodeType.Element == child.NodeType) { if (child.NamespaceURI == this.Schema.TargetNamespace) { this.Core.UnexpectedElement(node, child); } else { this.Core.UnsupportedExtensionElement(node, child); } } } if (String.IsNullOrEmpty(name)) { XmlAttribute productNameAttribute = node.ParentNode.Attributes["Name"]; if (null != productNameAttribute) { name = productNameAttribute.Value; } else { this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name, "Name")); } } if (!String.IsNullOrEmpty(name) && !CompilerCore.IsValidLongFilename(name, false)) { this.Core.OnMessage(TagErrors.IllegalName(sourceLineNumbers, node.ParentNode.LocalName, name)); } if (String.IsNullOrEmpty(regid)) { this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name, "Regid")); } if (!this.Core.EncounteredError) { string directoryId = "WixTagRegidFolder"; string fileId = this.Core.GenerateIdentifier("tag", regid, ".product.tag"); string fileName = String.Concat(regid, " ", name, ".swidtag"); string shortName = this.Core.GenerateShortName(fileName, false, false); this.Core.CreateWixSimpleReferenceRow(sourceLineNumbers, "Directory", directoryId); ComponentRow componentRow = (ComponentRow)this.Core.CreateRow(sourceLineNumbers, "Component"); componentRow.Component = fileId; componentRow.Guid = "*"; componentRow[3] = 0; componentRow.Directory = directoryId; componentRow.IsLocalOnly = true; componentRow.KeyPath = fileId; this.Core.CreateWixSimpleReferenceRow(sourceLineNumbers, "Feature", feature); this.Core.CreateComplexReference(sourceLineNumbers, ComplexReferenceParentType.Feature, feature, null, ComplexReferenceChildType.Component, fileId, true); FileRow fileRow = (FileRow)this.Core.CreateRow(sourceLineNumbers, "File"); fileRow.File = fileId; fileRow.Component = fileId; fileRow.FileName = String.Concat(shortName, "|", fileName); WixFileRow wixFileRow = (WixFileRow)this.Core.CreateRow(sourceLineNumbers, "WixFile"); wixFileRow.Directory = directoryId; wixFileRow.File = fileId; wixFileRow.DiskId = 1; wixFileRow.Attributes = 1; wixFileRow.Source = String.Concat("%TEMP%\\", fileName); this.Core.EnsureTable(sourceLineNumbers, "SoftwareIdentificationTag"); Row row = this.Core.CreateRow(sourceLineNumbers, "WixProductTag"); row[0] = fileId; row[1] = regid; row[2] = name; if (YesNoType.Yes == licensed) { row[3] = 1; } row[4] = type; this.Core.CreateWixSimpleReferenceRow(sourceLineNumbers, "File", fileId); } }
/// <summary> /// Parses a Tag element for Software Id Tag registration under a Bundle element. /// </summary> /// <param name="node">The element to parse.</param> private void ParseBundleTagElement(XmlNode node) { SourceLineNumberCollection sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string name = null; string regid = null; string installPath = null; foreach (XmlAttribute attrib in node.Attributes) { if (0 == attrib.NamespaceURI.Length || attrib.NamespaceURI == this.schema.TargetNamespace) { switch (attrib.LocalName) { case "Name": name = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false); break; case "Regid": regid = this.Core.GetAttributeValue(sourceLineNumbers, attrib); break; case "InstallDirectory": case "Win64": this.Core.OnMessage(WixErrors.ExpectedParentWithAttribute(sourceLineNumbers, node.Name, attrib.Name, "Product")); break; case "InstallPath": installPath = this.Core.GetAttributeValue(sourceLineNumbers, attrib); break; case "Licensed": this.Core.OnMessage(WixWarnings.DeprecatedAttribute(sourceLineNumbers, node.Name, attrib.Name)); break; case "Type": this.Core.OnMessage(WixWarnings.DeprecatedAttribute(sourceLineNumbers, node.Name, attrib.Name)); break; default: this.Core.UnexpectedAttribute(sourceLineNumbers, attrib); break; } } else { this.Core.UnsupportedExtensionAttribute(sourceLineNumbers, attrib); } } foreach (XmlNode child in node.ChildNodes) { if (XmlNodeType.Element == child.NodeType) { if (child.NamespaceURI == this.Schema.TargetNamespace) { this.Core.UnexpectedElement(node, child); } else { this.Core.UnsupportedExtensionElement(node, child); } } } if (String.IsNullOrEmpty(name)) { XmlAttribute productNameAttribute = node.ParentNode.Attributes["Name"]; if (null != productNameAttribute) { name = productNameAttribute.Value; } else { this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name, "Name")); } } if (!String.IsNullOrEmpty(name) && !CompilerCore.IsValidLongFilename(name, false)) { this.Core.OnMessage(TagErrors.IllegalName(sourceLineNumbers, node.ParentNode.LocalName, name)); } if (String.IsNullOrEmpty(regid)) { this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name, "Regid")); } else if (regid.StartsWith("regid.")) { this.Core.OnMessage(TagWarnings.DeprecatedRegidFormat(sourceLineNumbers, regid)); return; } else if (regid.Equals("example.com", StringComparison.OrdinalIgnoreCase)) { this.Core.OnMessage(TagErrors.ExampleRegid(sourceLineNumbers, regid)); return; } if (String.IsNullOrEmpty(installPath)) { this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name, "InstallPath")); } if (!this.Core.EncounteredError) { string fileName = String.Concat(name, ".swidtag"); Row tagRow = this.Core.CreateRow(sourceLineNumbers, "WixBundleTag"); tagRow[0] = fileName; tagRow[1] = regid; tagRow[2] = name; tagRow[3] = installPath; } }
/// <summary> /// Parses a Tag element for Software Id Tag registration under a Product element. /// </summary> /// <param name="node">The element to parse.</param> private void ParseProductTagElement(XmlNode node) { SourceLineNumberCollection sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string name = null; string regid = null; string feature = "WixSwidTag"; string installDirectory = null; bool win64 = (Platform.IA64 == this.Core.CurrentPlatform || Platform.X64 == this.Core.CurrentPlatform); foreach (XmlAttribute attrib in node.Attributes) { if (0 == attrib.NamespaceURI.Length || attrib.NamespaceURI == this.schema.TargetNamespace) { switch (attrib.LocalName) { case "Name": name = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false); break; case "Regid": regid = this.Core.GetAttributeValue(sourceLineNumbers, attrib); break; case "Feature": feature = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); break; case "InstallDirectory": installDirectory = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); break; case "InstallPath": this.Core.OnMessage(WixErrors.ExpectedParentWithAttribute(sourceLineNumbers, node.Name, attrib.Name, "Bundle")); break; case "Licensed": this.Core.OnMessage(WixWarnings.DeprecatedAttribute(sourceLineNumbers, node.Name, attrib.Name)); break; case "Type": this.Core.OnMessage(WixWarnings.DeprecatedAttribute(sourceLineNumbers, node.Name, attrib.Name)); break; case "Win64": win64 = (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)); break; default: this.Core.UnexpectedAttribute(sourceLineNumbers, attrib); break; } } else { this.Core.UnsupportedExtensionAttribute(sourceLineNumbers, attrib); } } foreach (XmlNode child in node.ChildNodes) { if (XmlNodeType.Element == child.NodeType) { if (child.NamespaceURI == this.Schema.TargetNamespace) { this.Core.UnexpectedElement(node, child); } else { this.Core.UnsupportedExtensionElement(node, child); } } } if (String.IsNullOrEmpty(name)) { XmlAttribute productNameAttribute = node.ParentNode.Attributes["Name"]; if (null != productNameAttribute) { name = productNameAttribute.Value; } else { this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name, "Name")); } } if (!String.IsNullOrEmpty(name) && !CompilerCore.IsValidLongFilename(name, false)) { this.Core.OnMessage(TagErrors.IllegalName(sourceLineNumbers, node.ParentNode.LocalName, name)); } if (String.IsNullOrEmpty(regid)) { this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name, "Regid")); } else if (regid.StartsWith("regid.")) { this.Core.OnMessage(TagWarnings.DeprecatedRegidFormat(sourceLineNumbers, regid)); return; } else if (regid.Equals("example.com", StringComparison.OrdinalIgnoreCase)) { this.Core.OnMessage(TagErrors.ExampleRegid(sourceLineNumbers, regid)); return; } if (String.IsNullOrEmpty(installDirectory)) { this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name, "InstallDirectory")); } if (!this.Core.EncounteredError) { string fileId = this.Core.GenerateIdentifier("tag", regid, ".product.tag"); string fileName = String.Concat(name, ".swidtag"); string shortName = this.Core.GenerateShortName(fileName, false, false); Row directoryRow = this.Core.CreateRow(sourceLineNumbers, "Directory"); directoryRow[0] = "WixTagInstallFolder"; directoryRow[1] = installDirectory; directoryRow[2] = "."; this.Core.CreateWixSimpleReferenceRow(sourceLineNumbers, "Directory", installDirectory); ComponentRow componentRow = (ComponentRow)this.Core.CreateRow(sourceLineNumbers, "Component"); componentRow.Component = fileId; componentRow.Guid = "*"; componentRow[3] = (win64 ? TagCompiler.MsidbComponentAttributes64bit : 0); componentRow.Directory = TagCompiler.TagFolderId; componentRow.IsLocalOnly = true; componentRow.KeyPath = fileId; this.Core.CreateWixSimpleReferenceRow(sourceLineNumbers, "Directory", TagCompiler.TagFolderId); this.Core.CreateWixSimpleReferenceRow(sourceLineNumbers, "Feature", feature); this.Core.CreateComplexReference(sourceLineNumbers, ComplexReferenceParentType.Feature, feature, null, ComplexReferenceChildType.Component, fileId, true); FileRow fileRow = (FileRow)this.Core.CreateRow(sourceLineNumbers, "File"); fileRow.File = fileId; fileRow.Component = fileId; fileRow.FileName = String.Concat(shortName, "|", fileName); WixFileRow wixFileRow = (WixFileRow)this.Core.CreateRow(sourceLineNumbers, "WixFile"); wixFileRow.Directory = TagCompiler.TagFolderId; wixFileRow.File = fileId; wixFileRow.DiskId = 1; wixFileRow.Attributes = 1; wixFileRow.Source = fileName; this.Core.EnsureTable(sourceLineNumbers, "SoftwareIdentificationTag"); Row row = this.Core.CreateRow(sourceLineNumbers, "WixProductTag"); row[0] = fileId; row[1] = regid; row[2] = name; this.Core.CreateWixSimpleReferenceRow(sourceLineNumbers, "File", fileId); } }
/// <summary> /// Parses a Tag element for Software Id Tag registration under a Bundle element. /// </summary> /// <param name="node">The element to parse.</param> private void ParseBundleTagElement(XElement node) { SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string name = null; string regid = null; YesNoType licensed = YesNoType.NotSet; string type = null; foreach (XAttribute attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { case "Name": name = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false); break; case "Regid": regid = this.Core.GetAttributeValue(sourceLineNumbers, attrib); break; case "Licensed": licensed = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); break; case "Type": type = this.ParseTagTypeAttribute(sourceLineNumbers, node, attrib); break; default: this.Core.UnexpectedAttribute(node, attrib); break; } } else { this.Core.ParseExtensionAttribute(node, attrib); } } this.Core.ParseForExtensionElements(node); if (String.IsNullOrEmpty(name)) { XAttribute productNameAttribute = node.Parent.Attribute("Name"); if (null != productNameAttribute) { name = productNameAttribute.Value; } else { this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Name")); } } if (!String.IsNullOrEmpty(name) && !this.Core.IsValidLongFilename(name, false)) { this.Core.OnMessage(TagErrors.IllegalName(sourceLineNumbers, node.Parent.Name.LocalName, name)); } if (String.IsNullOrEmpty(regid)) { this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Regid")); } if (!this.Core.EncounteredError) { string fileName = String.Concat(regid, " ", name, ".swidtag"); Row tagRow = this.Core.CreateRow(sourceLineNumbers, "WixBundleTag"); tagRow[0] = fileName; tagRow[1] = regid; tagRow[2] = name; if (YesNoType.Yes == licensed) { tagRow[3] = 1; } // field 4 is the TagXml set by the binder. tagRow[5] = type; } }
/// <summary> /// Parses a Tag element for Software Id Tag registration under a Bundle element. /// </summary> /// <param name="node">The element to parse.</param> private void ParseBundleTagElement(Intermediate intermediate, IntermediateSection section, XElement node) { var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); string name = null; string regid = null; var licensed = YesNoType.NotSet; string type = null; foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { case "Name": name = this.ParseHelper.GetAttributeLongFilename(sourceLineNumbers, attrib, false); break; case "Regid": regid = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "Licensed": licensed = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib); break; case "Type": type = this.ParseTagTypeAttribute(sourceLineNumbers, node, attrib); break; default: this.ParseHelper.UnexpectedAttribute(node, attrib); break; } } else { this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); } } this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); if (String.IsNullOrEmpty(name)) { var productNameAttribute = node.Parent.Attribute("Name"); if (null != productNameAttribute) { name = productNameAttribute.Value; } else { this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Name")); } } if (!String.IsNullOrEmpty(name) && !this.ParseHelper.IsValidLongFilename(name, false)) { this.Messaging.Write(TagErrors.IllegalName(sourceLineNumbers, node.Parent.Name.LocalName, name)); } if (String.IsNullOrEmpty(regid)) { this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Regid")); } if (!this.Messaging.EncounteredError) { var fileName = String.Concat(regid, " ", name, ".swidtag"); var tagSymbol = section.AddSymbol(new WixBundleTagSymbol(sourceLineNumbers) { Filename = fileName, Regid = regid, Name = name, // TagXml is set by the binder. Type = type, }); if (YesNoType.Yes == licensed) { tagSymbol.Attributes = 1; } } }
/// <summary> /// Parses a Tag element for Software Id Tag registration under a Product element. /// </summary> /// <param name="node">The element to parse.</param> private void ParsePackageTagElement(Intermediate intermediate, IntermediateSection section, XElement node) { var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); string name = null; string regid = null; var feature = "WixSwidTag"; var licensed = YesNoType.NotSet; string type = null; foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { case "Name": name = this.ParseHelper.GetAttributeLongFilename(sourceLineNumbers, attrib, false); break; case "Regid": regid = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "Feature": feature = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); break; case "Licensed": licensed = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib); break; case "Type": type = this.ParseTagTypeAttribute(sourceLineNumbers, node, attrib); break; default: this.ParseHelper.UnexpectedAttribute(node, attrib); break; } } else { this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); } } this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); if (String.IsNullOrEmpty(name)) { var productNameAttribute = node.Parent.Attribute("Name"); if (null != productNameAttribute) { name = productNameAttribute.Value; } else { this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Name")); } } if (!String.IsNullOrEmpty(name) && !this.ParseHelper.IsValidLongFilename(name, false)) { this.Messaging.Write(TagErrors.IllegalName(sourceLineNumbers, node.Parent.Name.LocalName, name)); } if (String.IsNullOrEmpty(regid)) { this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Regid")); } if (!this.Messaging.EncounteredError) { var directoryId = "WixTagRegidFolder"; var fileId = this.ParseHelper.CreateIdentifier("tag", regid, ".product.tag"); var fileName = String.Concat(regid, " ", name, ".swidtag"); var shortName = this.ParseHelper.CreateShortName(fileName, false, false); this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.Directory, directoryId); section.AddSymbol(new ComponentSymbol(sourceLineNumbers, fileId) { ComponentId = "*", DirectoryRef = directoryId, KeyPath = fileId.Id, }); this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.Feature, feature); this.ParseHelper.CreateComplexReference(section, sourceLineNumbers, ComplexReferenceParentType.Feature, feature, null, ComplexReferenceChildType.Component, fileId.Id, true); section.AddSymbol(new FileSymbol(sourceLineNumbers, fileId) { Attributes = FileSymbolAttributes.ReadOnly, ComponentRef = fileId.Id, DirectoryRef = directoryId, DiskId = 1, Name = fileName, ShortName = shortName, Source = new IntermediateFieldPathValue { Path = String.Concat("%TEMP%\\", fileName) }, }); this.ParseHelper.EnsureTable(section, sourceLineNumbers, TagTableDefinitions.SoftwareIdentificationTag); var symbol = section.AddSymbol(new WixProductTagSymbol(sourceLineNumbers, fileId) { Regid = regid, Name = name, Type = type, }); if (YesNoType.Yes == licensed) { symbol.Attributes = 1; } this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.File, fileId.Id); } }