public Identifier CreateRegistrySymbol(IntermediateSection section, SourceLineNumber sourceLineNumbers, RegistryRootType root, string key, string name, string value, string componentId, bool escapeLeadingHash) { if (RegistryRootType.Unknown == root) { throw new ArgumentOutOfRangeException(nameof(root)); } if (null == key) { throw new ArgumentNullException(nameof(key)); } if (null == componentId) { throw new ArgumentNullException(nameof(componentId)); } // Escape the leading '#' character for string registry values. if (escapeLeadingHash && null != value && value.StartsWith("#", StringComparison.Ordinal)) { value = String.Concat("#", value); } var id = this.CreateIdentifier("reg", componentId, ((int)root).ToString(CultureInfo.InvariantCulture.NumberFormat), key.ToLowerInvariant(), (null != name ? name.ToLowerInvariant() : name)); var symbol = section.AddSymbol(new RegistrySymbol(sourceLineNumbers, id) { Root = root, Key = key, Name = name, Value = value, ComponentRef = componentId, }); return(symbol.Id); }
public void CanSaveAndLoadMultipleIntermediateWithCustomDefinitionsAndTags() { var sln = new SourceLineNumber("test.wxs", 1); // Intermediate #1 var fieldDefs = new[] { new IntermediateFieldDefinition("A", IntermediateFieldType.String), new IntermediateFieldDefinition("B", IntermediateFieldType.Number), new IntermediateFieldDefinition("C", IntermediateFieldType.Bool), }; var symbolDef = new IntermediateSymbolDefinition("CustomDef", fieldDefs, null); symbolDef.AddTag("customDef"); var symbol = symbolDef.CreateSymbol(sln, new Identifier(AccessModifier.Global, "customT")); symbol.Set(0, "foo"); symbol.Set(1, 2); symbol.Set(2, true); symbol.AddTag("symbol1tag"); var section = new IntermediateSection("test", SectionType.Product); section.AddSymbol(symbol); var intermediate1 = new Intermediate("TestIntermediate", new[] { section }, null); // Intermediate #2 var fieldDefs2 = new[] { new IntermediateFieldDefinition("A", IntermediateFieldType.String), new IntermediateFieldDefinition("B", IntermediateFieldType.Number), new IntermediateFieldDefinition("C", IntermediateFieldType.Bool), new IntermediateFieldDefinition("D", IntermediateFieldType.String), }; var symbolDef2 = new IntermediateSymbolDefinition("CustomDef2", 1, fieldDefs2, null); symbolDef2.AddTag("customDef2"); symbolDef2.AddTag("customDef2 tag2"); var symbol2 = symbolDef2.CreateSymbol(sln, new Identifier(AccessModifier.Global, "customT2")); symbol2.Set(0, "bar"); symbol2.Set(1, 3); symbol2.Set(2, false); symbol2.Set(3, "baz"); symbol2.AddTag("symbol2tag1"); symbol2.AddTag("symbol2tag2"); var section2 = new IntermediateSection("test2", SectionType.Fragment); section2.AddSymbol(symbol2); var intermediate2 = new Intermediate("TestIntermediate2", new[] { section2 }, null); // Save var path1 = Path.GetTempFileName(); var path2 = Path.GetTempFileName(); try { intermediate1.Save(path1); intermediate2.Save(path2); var loaded = Intermediate.Load(new[] { path1, path2 }); var loaded1 = loaded.First(); var loaded2 = loaded.Skip(1).Single(); var loadedSymbol1 = loaded1.Sections.Single().Symbols.Single(); var loadedSymbol2 = loaded2.Sections.Single().Symbols.Single(); Assert.True(loadedSymbol1.Definition.HasTag("customDef")); Assert.Equal("foo", loadedSymbol1.AsString(0)); Assert.Equal(2, loadedSymbol1[1].AsNumber()); Assert.True(loadedSymbol1[2].AsBool()); Assert.True(loadedSymbol1.HasTag("symbol1tag")); Assert.True(loadedSymbol2.Definition.HasTag("customDef2")); Assert.True(loadedSymbol2.Definition.HasTag("customDef2 tag2")); Assert.Equal("bar", loadedSymbol2.AsString(0)); Assert.Equal(3, loadedSymbol2[1].AsNumber()); Assert.False(loadedSymbol2[2].AsBool()); Assert.Equal("baz", loadedSymbol2.AsString(3)); Assert.True(loadedSymbol2.HasTag("symbol2tag1")); Assert.True(loadedSymbol2.HasTag("symbol2tag2")); } finally { File.Delete(path2); File.Delete(path1); } }
/// <summary> /// Parses an MSMQ message queue permission element. /// </summary> /// <param name="node">Element to parse.</param> /// <param name="componentKey">Identifier of parent component.</param> /// <param name="applicationKey">Optional identifier of parent message queue.</param> private void ParseMessageQueuePermissionElement(Intermediate intermediate, IntermediateSection section, XElement node, string componentId, string messageQueueId) { var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); Identifier id = null; string user = null; string group = null; int permissions = 0; foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { case "Id": id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); break; case "MessageQueue": if (null != messageQueueId) { this.Messaging.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, node.Parent.Name.LocalName)); } messageQueueId = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, MsmqSymbolDefinitions.MessageQueue, messageQueueId); break; case "User": if (null != group) { this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "User", "Group")); } user = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "User", user); break; case "Group": if (null != user) { this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "Group", "User")); } group = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "Group", group); break; case "DeleteMessage": if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { permissions |= (int)MqiMessageQueuePermission.DeleteMessage; } else { permissions &= ~(int)MqiMessageQueuePermission.DeleteMessage; } break; case "PeekMessage": if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { permissions |= (int)MqiMessageQueuePermission.PeekMessage; } else { permissions &= ~(int)MqiMessageQueuePermission.PeekMessage; } break; case "WriteMessage": if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { permissions |= (int)MqiMessageQueuePermission.WriteMessage; } else { permissions &= ~(int)MqiMessageQueuePermission.WriteMessage; } break; case "DeleteJournalMessage": if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { permissions |= (int)MqiMessageQueuePermission.DeleteJournalMessage; } else { permissions &= ~(int)MqiMessageQueuePermission.DeleteJournalMessage; } break; case "SetQueueProperties": if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { permissions |= (int)MqiMessageQueuePermission.SetQueueProperties; } else { permissions &= ~(int)MqiMessageQueuePermission.SetQueueProperties; } break; case "GetQueueProperties": if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { permissions |= (int)MqiMessageQueuePermission.GetQueueProperties; } else { permissions &= ~(int)MqiMessageQueuePermission.GetQueueProperties; } break; case "DeleteQueue": if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { permissions |= (int)MqiMessageQueuePermission.DeleteQueue; } else { permissions &= ~(int)MqiMessageQueuePermission.DeleteQueue; } break; case "GetQueuePermissions": if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { permissions |= (int)MqiMessageQueuePermission.GetQueuePermissions; } else { permissions &= ~(int)MqiMessageQueuePermission.GetQueuePermissions; } break; case "ChangeQueuePermissions": if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { permissions |= (int)MqiMessageQueuePermission.ChangeQueuePermissions; } else { permissions &= ~(int)MqiMessageQueuePermission.ChangeQueuePermissions; } break; case "TakeQueueOwnership": if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { permissions |= (int)MqiMessageQueuePermission.TakeQueueOwnership; } else { permissions &= ~(int)MqiMessageQueuePermission.TakeQueueOwnership; } break; case "ReceiveMessage": if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { permissions |= (int)MqiMessageQueuePermission.ReceiveMessage; } else { permissions &= ~(int)MqiMessageQueuePermission.ReceiveMessage; } break; case "ReceiveJournalMessage": if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { permissions |= (int)MqiMessageQueuePermission.ReceiveJournalMessage; } else { permissions &= ~(int)MqiMessageQueuePermission.ReceiveJournalMessage; } break; case "QueueGenericRead": if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { permissions |= (int)MqiMessageQueuePermission.QueueGenericRead; } else { permissions &= ~(int)MqiMessageQueuePermission.QueueGenericRead; } break; case "QueueGenericWrite": if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { permissions |= (int)MqiMessageQueuePermission.QueueGenericWrite; } else { permissions &= ~(int)MqiMessageQueuePermission.QueueGenericWrite; } break; case "QueueGenericExecute": if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { permissions |= (int)MqiMessageQueuePermission.QueueGenericExecute; } else { permissions &= ~(int)MqiMessageQueuePermission.QueueGenericExecute; } break; case "QueueGenericAll": if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { permissions |= (int)MqiMessageQueuePermission.QueueGenericAll; } else { permissions &= ~(int)MqiMessageQueuePermission.QueueGenericAll; } break; default: this.ParseHelper.UnexpectedAttribute(node, attrib); break; } } else { this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); } } if (null == id) { id = this.ParseHelper.CreateIdentifier("mqp", componentId, messageQueueId, user, group); } if (null == messageQueueId) { this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "MessageQueue")); } if (null == user && null == group) { this.Messaging.Write(ErrorMessages.ExpectedAttributes(sourceLineNumbers, node.Name.LocalName, "User", "Group")); } this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); if (null != user) { section.AddSymbol(new MessageQueueUserPermissionSymbol(sourceLineNumbers, id) { ComponentRef = componentId, MessageQueueRef = messageQueueId, UserRef = user, Permissions = permissions, }); } if (null != group) { section.AddSymbol(new MessageQueueGroupPermissionSymbol(sourceLineNumbers, id) { ComponentRef = componentId, MessageQueueRef = messageQueueId, GroupRef = group, Permissions = permissions, }); } }
/// <summary> /// Parses a sql string element. /// </summary> /// <param name="element">Element to parse.</param> /// <param name="componentId">Identifier for parent component.</param> /// <param name="sqlDb">Optional database to execute string against.</param> private void ParseSqlStringElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId, string sqlDb) { var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); Identifier id = null; int attributes = 0; var rollbackAttribute = false; var nonRollbackAttribute = false; var sequence = CompilerConstants.IntegerNotSet; string sql = null; string user = null; foreach (var attrib in element.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { case "Id": id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); break; case "ContinueOnError": if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= SqlContinueOnError; } break; case "ExecuteOnInstall": if (rollbackAttribute) { this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); } nonRollbackAttribute = true; if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= SqlExecuteOnInstall; } break; case "ExecuteOnReinstall": if (rollbackAttribute) { this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); } nonRollbackAttribute = true; if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= SqlExecuteOnReinstall; } break; case "ExecuteOnUninstall": if (rollbackAttribute) { this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); } nonRollbackAttribute = true; if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= SqlExecuteOnUninstall; } break; case "RollbackOnInstall": if (nonRollbackAttribute) { this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); } rollbackAttribute = true; if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= SqlExecuteOnInstall; attributes |= SqlRollback; } break; case "RollbackOnReinstall": if (nonRollbackAttribute) { this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); } rollbackAttribute = true; if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= SqlExecuteOnReinstall; attributes |= SqlRollback; } break; case "RollbackOnUninstall": if (nonRollbackAttribute) { this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); } rollbackAttribute = true; if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= SqlExecuteOnUninstall; attributes |= SqlRollback; } break; case "Sequence": sequence = this.ParseHelper.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, short.MaxValue); break; case "SQL": sql = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "SqlDb": if (null != sqlDb) { this.Messaging.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, element.Name.LocalName, "SqlDb", "SqlDatabase")); } sqlDb = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SqlSymbolDefinitions.SqlDatabase, sqlDb); break; case "User": user = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "User", user); break; default: this.ParseHelper.UnexpectedAttribute(element, attrib); break; } } else { this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); } } if (null == id) { id = this.ParseHelper.CreateIdentifier("sst", componentId, sql, sqlDb); } if (null == sql) { this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "SQL")); } if (null == sqlDb) { this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "SqlDb")); } if (0 == attributes) { this.Messaging.Write(ErrorMessages.ExpectedAttributes(sourceLineNumbers, element.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall", "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); } this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); // Reference InstallSqlData and UninstallSqlData since nothing will happen without it this.AddReferenceToInstallSqlData(section, sourceLineNumbers); if (!this.Messaging.EncounteredError) { var symbol = section.AddSymbol(new SqlStringSymbol(sourceLineNumbers, id) { SqlDbRef = sqlDb, ComponentRef = componentId, SQL = sql, UserRef = user, Attributes = attributes, }); if (CompilerConstants.IntegerNotSet != sequence) { symbol.Sequence = sequence; } } }
public IntermediateSymbol CreateSymbol(IntermediateSection section, SourceLineNumber sourceLineNumbers, IntermediateSymbolDefinition symbolDefinition, Identifier identifier = null) { return(section.AddSymbol(symbolDefinition.CreateSymbol(sourceLineNumbers, identifier))); }
private void ParsePlugCollectionIntoElement(Intermediate intermediate, IntermediateSection section, XElement element, Identifier parentId) { var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); string hxa = null; string hxt = null; string hxtParent = null; string namespaceParent = null; string feature = null; var suppressExternalNamespaces = YesNoType.No; foreach (var attrib in element.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { case "Attributes": hxa = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); break; case "TableOfContents": hxt = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); break; case "TargetCollection": namespaceParent = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); break; case "TargetTableOfContents": hxtParent = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); break; case "TargetFeature": feature = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); break; case "SuppressExternalNamespaces": suppressExternalNamespaces = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib); break; default: this.ParseHelper.UnexpectedAttribute(element, attrib); break; } } else { this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); } } var pluginVS05 = namespaceParent.Equals("MS_VSIPCC_v80", StringComparison.Ordinal); var pluginVS08 = namespaceParent.Equals("MS.VSIPCC.v90", StringComparison.Ordinal); if (null == namespaceParent) { this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "TargetCollection")); } if (null == feature && (pluginVS05 || pluginVS08) && YesNoType.No == suppressExternalNamespaces) { this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "TargetFeature")); } this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); if (!this.Messaging.EncounteredError) { section.AddSymbol(new HelpPluginSymbol(sourceLineNumbers, parentId) { HelpNamespaceRef = parentId.Id, ParentHelpNamespaceRef = namespaceParent, HxTFileRef = hxt, HxAFileRef = hxa, ParentHxTFileRef = hxtParent, }); if (pluginVS05) { if (YesNoType.No == suppressExternalNamespaces) { // Bring in the help 2 base namespace components for VS 2005 this.ParseHelper.CreateComplexReference(section, sourceLineNumbers, ComplexReferenceParentType.Feature, feature, String.Empty, ComplexReferenceChildType.ComponentGroup, "Help2_VS2005_Namespace_Components", false); // Reference CustomAction since nothing will happen without it this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.CustomAction, "CA_HxMerge_VSIPCC_VSCC"); } } else if (pluginVS08) { if (YesNoType.No == suppressExternalNamespaces) { // Bring in the help 2 base namespace components for VS 2008 this.ParseHelper.CreateComplexReference(section, sourceLineNumbers, ComplexReferenceParentType.Feature, feature, String.Empty, ComplexReferenceChildType.ComponentGroup, "Help2_VS2008_Namespace_Components", false); // Reference CustomAction since nothing will happen without it this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.CustomAction, "CA_ScheduleExtHelpPlugin_VSCC_VSIPCC"); } } else { // Reference the parent namespace to enforce the foreign key relationship this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, VSSymbolDefinitions.HelpNamespace, namespaceParent); } } }
private void ParseHelpFileElement(Intermediate intermediate, IntermediateSection section, XElement element, string fileId) { var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); Identifier id = null; string name = null; var language = CompilerConstants.IntegerNotSet; string hxi = null; string hxq = null; string hxr = null; string samples = null; var suppressCAs = YesNoType.No; foreach (var attrib in element.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { case "Id": id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); break; case "AttributeIndex": hxr = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.File, hxr); break; case "Index": hxi = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.File, hxi); break; case "Language": language = this.ParseHelper.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue); break; case "Name": name = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "SampleLocation": samples = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.File, samples); break; case "Search": hxq = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.File, hxq); break; case "SuppressCustomActions": suppressCAs = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib); break; default: this.ParseHelper.UnexpectedAttribute(element, attrib); break; } } else { this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); } } if (null == id) { id = this.ParseHelper.CreateIdentifier("vshf", fileId, name, language.ToString(CultureInfo.InvariantCulture.NumberFormat)); } if (null == name) { this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Name")); } // Uninstall will always fail silently, leaving file registered, if Language is not set if (CompilerConstants.IntegerNotSet == language) { this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Language")); } this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); if (!this.Messaging.EncounteredError) { section.AddSymbol(new HelpFileSymbol(sourceLineNumbers, id) { HelpFileName = name, LangID = language, HxSFileRef = fileId, HxIFileRef = hxi, HxQFileRef = hxq, HxRFileRef = hxr, SamplesFileRef = samples, }); if (YesNoType.No == suppressCAs) { this.AddReferenceToRegisterMicrosoftHelp(section, sourceLineNumbers); } } }
/// <summary> /// Parses a SniSsl element. /// </summary> /// <param name="node">The element to parse.</param> /// <param name="componentId">Identifier of the component that owns this SNI SSL Certificate.</param> private void ParseSniSslCertificateElement(Intermediate intermediate, IntermediateSection section, XElement node, string componentId) { var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); Identifier id = null; string host = null; string port = null; string appId = null; string store = null; string thumbprint = null; var handleExisting = HandleExisting.Replace; string handleExistingValue = null; foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { case "Id": id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); break; case "AppId": appId = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "HandleExisting": handleExistingValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); switch (handleExistingValue) { case "replace": handleExisting = HandleExisting.Replace; break; case "ignore": handleExisting = HandleExisting.Ignore; break; case "fail": handleExisting = HandleExisting.Fail; break; default: this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "HandleExisting", handleExistingValue, "replace", "ignore", "fail")); break; } break; case "Host": host = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "Port": port = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "Store": store = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "Thumbprint": thumbprint = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; default: this.ParseHelper.UnexpectedAttribute(node, attrib); break; } } else { this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); } } // Need the element ID for child element processing, so generate now if not authored. if (null == id) { id = this.ParseHelper.CreateIdentifier("ssl", componentId, host, port); } // Required attributes. if (null == host) { this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Host")); } if (null == port) { this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Port")); } if (null == thumbprint) { this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Thumbprint")); } // Parse unknown children. this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); if (!this.Messaging.EncounteredError) { section.AddSymbol(new WixHttpSniSslCertSymbol(sourceLineNumbers, id) { Host = host, Port = port, Thumbprint = thumbprint, AppId = appId, Store = store, HandleExisting = handleExisting, ComponentRef = componentId, }); this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4SchedHttpSniSslCertsInstall", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64); this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4SchedHttpSniSslCertsUninstall", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64); } }
/// <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(Intermediate intermediate, IntermediateSection section, XElement parentElement, XAttribute attribute, IDictionary <string, string> context) { var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(parentElement); WixMbaPrereqInformationSymbol prereqInfo; switch (parentElement.Name.LocalName) { case "ExePackage": case "MsiPackage": case "MspPackage": case "MsuPackage": string packageId; if (!context.TryGetValue("PackageId", out packageId) || String.IsNullOrEmpty(packageId)) { this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, parentElement.Name.LocalName, "Id", attribute.Name.LocalName)); } else { switch (attribute.Name.LocalName) { case "DisplayInternalUICondition": switch (parentElement.Name.LocalName) { case "MsiPackage": case "MspPackage": var displayInternalUICondition = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attribute); section.AddSymbol(new WixBalPackageInfoSymbol(sourceLineNumbers, new Identifier(AccessModifier.Public, packageId)) { PackageId = packageId, DisplayInternalUICondition = displayInternalUICondition, }); break; default: this.ParseHelper.UnexpectedAttribute(parentElement, attribute); break; } break; case "PrereqLicenseFile": if (!this.prereqInfoSymbolsByPackageId.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. var prereqPackage = parentElement.Attribute(this.Namespace + "PrereqPackage"); if (null != prereqPackage && YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, prereqPackage)) { prereqInfo = section.AddSymbol(new WixMbaPrereqInformationSymbol(sourceLineNumbers) { PackageId = packageId, }); this.prereqInfoSymbolsByPackageId.Add(packageId, prereqInfo); } else { this.Messaging.Write(BalErrors.AttributeRequiresPrereqPackage(sourceLineNumbers, parentElement.Name.LocalName, "PrereqLicenseFile")); break; } } if (null != prereqInfo.LicenseUrl) { this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, parentElement.Name.LocalName, "PrereqLicenseFile", "PrereqLicenseUrl")); } else { prereqInfo.LicenseFile = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attribute); } break; case "PrereqLicenseUrl": if (!this.prereqInfoSymbolsByPackageId.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. var prereqPackage = parentElement.Attribute(this.Namespace + "PrereqPackage"); if (null != prereqPackage && YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, prereqPackage)) { prereqInfo = section.AddSymbol(new WixMbaPrereqInformationSymbol(sourceLineNumbers) { PackageId = packageId, }); this.prereqInfoSymbolsByPackageId.Add(packageId, prereqInfo); } else { this.Messaging.Write(BalErrors.AttributeRequiresPrereqPackage(sourceLineNumbers, parentElement.Name.LocalName, "PrereqLicenseUrl")); break; } } if (null != prereqInfo.LicenseFile) { this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, parentElement.Name.LocalName, "PrereqLicenseUrl", "PrereqLicenseFile")); } else { prereqInfo.LicenseUrl = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attribute); } break; case "PrereqPackage": if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attribute)) { if (!this.prereqInfoSymbolsByPackageId.TryGetValue(packageId, out prereqInfo)) { prereqInfo = section.AddSymbol(new WixMbaPrereqInformationSymbol(sourceLineNumbers) { PackageId = packageId, }); this.prereqInfoSymbolsByPackageId.Add(packageId, prereqInfo); } } break; default: this.ParseHelper.UnexpectedAttribute(parentElement, attribute); break; } } break; case "Payload": string payloadId; if (!context.TryGetValue("Id", out payloadId) || String.IsNullOrEmpty(payloadId)) { this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, parentElement.Name.LocalName, "Id", attribute.Name.LocalName)); } else { switch (attribute.Name.LocalName) { case "BAFactoryAssembly": if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attribute)) { // There can only be one. var id = new Identifier(AccessModifier.Public, "TheBAFactoryAssembly"); section.AddSymbol(new WixBalBAFactoryAssemblySymbol(sourceLineNumbers, id) { PayloadId = payloadId, }); } break; case "BAFunctions": if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attribute)) { section.AddSymbol(new WixBalBAFunctionsSymbol(sourceLineNumbers) { PayloadId = payloadId, }); } break; default: this.ParseHelper.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. var variableName = parentElement.Attribute("Name"); if (null == variableName) { this.Messaging.Write(ErrorMessages.ExpectedParentWithAttribute(sourceLineNumbers, "Variable", "Overridable", "Name")); } else { switch (attribute.Name.LocalName) { case "Overridable": if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attribute)) { section.AddSymbol(new WixStdbaOverridableVariableSymbol(sourceLineNumbers) { Name = variableName.Value, }); } break; default: this.ParseHelper.UnexpectedAttribute(parentElement, attribute); break; } } break; } }
private void ParseExampleSearchElement(Intermediate intermediate, IntermediateSection section, XElement element) { var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); Identifier id = null; string searchFor = null; string variable = null; string condition = null; string after = null; foreach (var attrib in element.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { case "Id": id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); break; case "Variable": variable = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "Condition": condition = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "After": after = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "SearchFor": searchFor = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; default: this.ParseHelper.UnexpectedAttribute(element, attrib); break; } } else { this.ParseAttribute(intermediate, section, element, attrib, null); } } if (null == id) { this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id")); } if (!this.Messaging.EncounteredError) { this.ParseHelper.CreateWixSearchSymbol(section, sourceLineNumbers, element.Name.LocalName, id, variable, condition, after, this.BundleExtensionId); } if (!this.Messaging.EncounteredError) { var symbol = section.AddSymbol(new ExampleSearchSymbol(sourceLineNumbers, id) { SearchFor = searchFor, }); } }
/// <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); } }
/// <summary> /// Processes the Requires element. /// </summary> /// <param name="node">The XML node for the Requires element.</param> /// <param name="providerId">The parent provider identifier.</param> /// <param name="requiresAction">Whether the Requires custom action should be referenced.</param> private void ParseRequiresElement(Intermediate intermediate, IntermediateSection section, XElement node, string providerId, bool requiresAction) { var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); Identifier id = null; string providerKey = null; string minVersion = null; string maxVersion = null; int attributes = 0; int illegalChar = -1; foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { case "Id": id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); break; case "ProviderKey": providerKey = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "Minimum": minVersion = this.ParseHelper.GetAttributeVersionValue(sourceLineNumbers, attrib); break; case "Maximum": maxVersion = this.ParseHelper.GetAttributeVersionValue(sourceLineNumbers, attrib); break; case "IncludeMinimum": if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= DependencyCommon.RequiresAttributesMinVersionInclusive; } break; case "IncludeMaximum": if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= DependencyCommon.RequiresAttributesMaxVersionInclusive; } 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 (null == id) { // Generate an ID only if this element is authored under a Provides element; otherwise, a RequiresRef // element will be necessary and the Id attribute will be required. if (!String.IsNullOrEmpty(providerId)) { id = this.ParseHelper.CreateIdentifier("dep", node.Name.LocalName, providerKey); } else { this.Messaging.Write(ErrorMessages.ExpectedAttributeWhenElementNotUnderElement(sourceLineNumbers, node.Name.LocalName, "Id", "Provides")); id = Identifier.Invalid; } } if (String.IsNullOrEmpty(providerKey)) { this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "ProviderKey")); } // Make sure the key does not contain any illegal characters. else if (0 <= (illegalChar = providerKey.IndexOfAny(DependencyCommon.InvalidCharacters))) { var sb = new StringBuilder(DependencyCommon.InvalidCharacters.Length * 2); Array.ForEach <char>(DependencyCommon.InvalidCharacters, c => sb.Append(c).Append(" ")); this.Messaging.Write(DependencyErrors.IllegalCharactersInProvider(sourceLineNumbers, "ProviderKey", providerKey[illegalChar], sb.ToString())); } if (!this.Messaging.EncounteredError) { // Reference the Require custom action if required. if (requiresAction) { this.AddReferenceToWixDependencyRequire(section, sourceLineNumbers); } var symbol = section.AddSymbol(new WixDependencySymbol(sourceLineNumbers, id) { ProviderKey = providerKey, MinVersion = minVersion, MaxVersion = maxVersion, }); if (0 != attributes) { symbol.Attributes = attributes; } // Create the relationship between this WixDependency symbol and the WixDependencyProvider symbol. if (!String.IsNullOrEmpty(providerId)) { section.AddSymbol(new WixDependencyRefSymbol(sourceLineNumbers) { WixDependencyProviderRef = providerId, WixDependencyRef = id.Id, }); } } }
/// <summary> /// Processes the Provides element. /// </summary> /// <param name="node">The XML node for the Provides element.</param> /// <param name="packageType">The type of the package being chained into a bundle, or "None" if building an MSI package.</param> /// <param name="keyPath">Explicit key path.</param> /// <param name="parentId">The identifier of the parent component or package.</param> /// <returns>The type of key path if set.</returns> private IComponentKeyPath ParseProvidesElement(Intermediate intermediate, IntermediateSection section, XElement node, PackageType packageType, string parentId) { var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); IComponentKeyPath keyPath = null; Identifier id = null; string key = null; string version = null; string displayName = null; int illegalChar = -1; foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { case "Id": id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); break; case "Key": key = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "Version": version = this.ParseHelper.GetAttributeVersionValue(sourceLineNumbers, attrib); break; case "DisplayName": displayName = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; default: this.ParseHelper.UnexpectedAttribute(node, attrib); break; } } else { this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); } } // Make sure the key is valid. The key will default to the ProductCode for MSI packages // and the package code for MSP packages in the binder if not specified. if (!String.IsNullOrEmpty(key)) { // Make sure the key does not contain any illegal characters or values. if (0 <= (illegalChar = key.IndexOfAny(DependencyCommon.InvalidCharacters))) { var sb = new StringBuilder(DependencyCommon.InvalidCharacters.Length * 2); Array.ForEach <char>(DependencyCommon.InvalidCharacters, c => sb.Append(c).Append(" ")); this.Messaging.Write(DependencyErrors.IllegalCharactersInProvider(sourceLineNumbers, "Key", key[illegalChar], sb.ToString())); } else if ("ALL" == key) { this.Messaging.Write(DependencyErrors.ReservedValue(sourceLineNumbers, node.Name.LocalName, "Key", key)); } } else if (PackageType.ExePackage == packageType || PackageType.MsuPackage == packageType) { // Must specify the provider key when authored for a package. this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Key")); } else if (PackageType.None == packageType) { // Make sure the ProductCode is authored and set the key. this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.Property, "ProductCode"); key = "!(bind.property.ProductCode)"; } // The Version attribute should not be authored in or for an MSI package. if (!String.IsNullOrEmpty(version)) { switch (packageType) { case PackageType.None: this.Messaging.Write(DependencyWarnings.DiscouragedVersionAttribute(sourceLineNumbers)); break; case PackageType.MsiPackage: this.Messaging.Write(DependencyWarnings.DiscouragedVersionAttribute(sourceLineNumbers, parentId)); break; } } else if (PackageType.MspPackage == packageType || PackageType.MsuPackage == packageType) { // Must specify the Version when authored for packages that do not contain a version. this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Version")); } // Need the element ID for child element processing, so generate now if not authored. if (null == id) { id = this.ParseHelper.CreateIdentifier("dep", node.Name.LocalName, parentId, key); } foreach (var child in node.Elements()) { if (this.Namespace == child.Name.Namespace) { switch (child.Name.LocalName) { case "Requires": this.ParseRequiresElement(intermediate, section, child, id.Id, PackageType.None == packageType); break; case "RequiresRef": this.ParseRequiresRefElement(intermediate, section, child, id.Id, PackageType.None == packageType); break; default: this.ParseHelper.UnexpectedElement(node, child); break; } } else { this.ParseHelper.ParseExtensionElement(this.Context.Extensions, intermediate, section, node, child); } } if (!this.Messaging.EncounteredError) { var symbol = section.AddSymbol(new WixDependencyProviderSymbol(sourceLineNumbers, id) { ComponentRef = parentId, ProviderKey = key, }); if (!String.IsNullOrEmpty(version)) { symbol.Version = version; } if (!String.IsNullOrEmpty(displayName)) { symbol.DisplayName = displayName; } if (PackageType.None == packageType) { this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "DependencyCheck", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64); // Generate registry rows for the provider using binder properties. var keyProvides = String.Concat(DependencyCommon.RegistryRoot, key); var root = RegistryRootType.MachineUser; var value = "[ProductCode]"; this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, root, keyProvides, null, value, parentId, false); value = !String.IsNullOrEmpty(version) ? version : "[ProductVersion]"; var versionRegistrySymbol = this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, root, keyProvides, "Version", value, parentId, false); value = !String.IsNullOrEmpty(displayName) ? displayName : "[ProductName]"; this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, root, keyProvides, "DisplayName", value, parentId, false); // Use the Version registry value and use that as a potential key path. keyPath = this.CreateComponentKeyPath(); keyPath.Id = versionRegistrySymbol.Id; keyPath.Explicit = false; keyPath.Type = PossibleKeyPathType.Registry; } } return(keyPath); }
/// <summary> /// Parses a UrlReservation element. /// </summary> /// <param name="node">The element to parse.</param> /// <param name="componentId">Identifier of the component that owns this URL reservation.</param> /// <param name="securityPrincipal">The security principal of the parent element (null if nested under Component).</param> private void ParseUrlReservationElement(Intermediate intermediate, IntermediateSection section, XElement node, string componentId, string securityPrincipal) { var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); Identifier id = null; var handleExisting = HandleExisting.Replace; string sddl = null; string url = null; var foundACE = false; foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { case "Id": id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); break; case "HandleExisting": var handleExistingValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); switch (handleExistingValue) { case "replace": handleExisting = HandleExisting.Replace; break; case "ignore": handleExisting = HandleExisting.Ignore; break; case "fail": handleExisting = HandleExisting.Fail; break; default: this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "HandleExisting", handleExistingValue, "replace", "ignore", "fail")); break; } break; case "Sddl": sddl = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "Url": url = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; default: this.ParseHelper.UnexpectedAttribute(node, attrib); break; } } else { this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); } } // Need the element ID for child element processing, so generate now if not authored. if (null == id) { id = this.ParseHelper.CreateIdentifier("url", componentId, securityPrincipal, url); } // Parse UrlAce children. foreach (var child in node.Elements()) { if (this.Namespace == child.Name.Namespace) { switch (child.Name.LocalName) { case "UrlAce": if (null != sddl) { this.Messaging.Write(ErrorMessages.IllegalParentAttributeWhenNested(sourceLineNumbers, "UrlReservation", "Sddl", "UrlAce")); } else { foundACE = true; this.ParseUrlAceElement(intermediate, section, child, id.Id, securityPrincipal); } break; default: this.ParseHelper.UnexpectedElement(node, child); break; } } else { this.ParseHelper.ParseExtensionElement(this.Context.Extensions, intermediate, section, node, child); } } // Url is required. if (null == url) { this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Url")); } // Security is required. if (null == sddl && !foundACE) { this.Messaging.Write(HttpErrors.NoSecuritySpecified(sourceLineNumbers)); } if (!this.Messaging.EncounteredError) { section.AddSymbol(new WixHttpUrlReservationSymbol(sourceLineNumbers, id) { HandleExisting = handleExisting, Sddl = sddl, Url = url, ComponentRef = componentId, }); this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4SchedHttpUrlReservationsInstall", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64); this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4SchedHttpUrlReservationsUninstall", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64); } }
/// <summary> /// Parses a UrlAce element. /// </summary> /// <param name="node">The element to parse.</param> /// <param name="urlReservationId">The URL reservation ID.</param> /// <param name="defaultSecurityPrincipal">The default security principal.</param> private void ParseUrlAceElement(Intermediate intermediate, IntermediateSection section, XElement node, string urlReservationId, string defaultSecurityPrincipal) { var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); Identifier id = null; var securityPrincipal = defaultSecurityPrincipal; var rights = HttpConstants.GENERIC_ALL; string rightsValue = null; foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { case "Id": id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); break; case "SecurityPrincipal": securityPrincipal = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "Rights": rightsValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); switch (rightsValue) { case "all": rights = HttpConstants.GENERIC_ALL; break; case "delegate": rights = HttpConstants.GENERIC_WRITE; break; case "register": rights = HttpConstants.GENERIC_EXECUTE; break; default: this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Rights", rightsValue, "all", "delegate", "register")); break; } break; default: this.ParseHelper.UnexpectedAttribute(node, attrib); break; } } else { this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); } } // Generate Id now if not authored. if (null == id) { id = this.ParseHelper.CreateIdentifier("ace", urlReservationId, securityPrincipal, rightsValue); } this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); // SecurityPrincipal is required. if (null == securityPrincipal) { this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "SecurityPrincipal")); } if (!this.Messaging.EncounteredError) { section.AddSymbol(new WixHttpUrlAceSymbol(sourceLineNumbers, id) { WixHttpUrlReservationRef = urlReservationId, SecurityPrincipal = securityPrincipal, Rights = rights, }); } }
/// <summary> /// Parses a WixStandardBootstrapperApplication element for Bundles. /// </summary> /// <param name="node">The element to parse.</param> private void ParseWixStandardBootstrapperApplicationElement(Intermediate intermediate, IntermediateSection section, XElement node) { var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); string launchTarget = null; string launchTargetElevatedId = null; string launchArguments = null; var launchHidden = YesNoType.NotSet; string launchWorkingDir = null; string licenseFile = null; string licenseUrl = null; string logoFile = null; string logoSideFile = null; WixStandardBootstrapperApplicationTheme?theme = null; string themeFile = null; string localizationFile = null; var suppressOptionsUI = YesNoType.NotSet; var suppressDowngradeFailure = YesNoType.NotSet; var suppressRepair = YesNoType.NotSet; var showVersion = YesNoType.NotSet; var supportCacheOnly = YesNoType.NotSet; foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { case "LaunchTarget": launchTarget = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "LaunchTargetElevatedId": launchTargetElevatedId = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); break; case "LaunchArguments": launchArguments = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "LaunchHidden": launchHidden = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib); break; case "LaunchWorkingFolder": launchWorkingDir = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "LicenseFile": licenseFile = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "LicenseUrl": licenseUrl = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); break; case "LogoFile": logoFile = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "LogoSideFile": logoSideFile = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "ThemeFile": themeFile = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "LocalizationFile": localizationFile = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "SuppressOptionsUI": suppressOptionsUI = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib); break; case "SuppressDowngradeFailure": suppressDowngradeFailure = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib); break; case "SuppressRepair": suppressRepair = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib); break; case "ShowVersion": showVersion = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib); break; case "SupportCacheOnly": supportCacheOnly = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib); break; case "Theme": var themeValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); switch (themeValue) { case "hyperlinkLargeLicense": theme = WixStandardBootstrapperApplicationTheme.HyperlinkLargeLicense; break; case "hyperlinkLicense": theme = WixStandardBootstrapperApplicationTheme.HyperlinkLicense; break; case "hyperlinkSidebarLicense": theme = WixStandardBootstrapperApplicationTheme.HyperlinkSidebarLicense; break; case "none": theme = WixStandardBootstrapperApplicationTheme.None; break; case "rtfLargeLicense": theme = WixStandardBootstrapperApplicationTheme.RtfLargeLicense; break; case "rtfLicense": theme = WixStandardBootstrapperApplicationTheme.RtfLicense; break; default: this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Theme", themeValue, "hyperlinkLargeLicense", "hyperlinkLicense", "hyperlinkSidebarLicense", "none", "rtfLargeLicense", "rtfLicense")); theme = WixStandardBootstrapperApplicationTheme.Unknown; // set a value to prevent expected attribute error below. break; } 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 (!theme.HasValue) { this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Theme")); } if (theme != WixStandardBootstrapperApplicationTheme.None && String.IsNullOrEmpty(licenseFile) && null == licenseUrl) { this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "LicenseFile", "LicenseUrl", true)); } if (!this.Messaging.EncounteredError) { if (!String.IsNullOrEmpty(launchTarget)) { section.AddSymbol(new WixBundleVariableSymbol(sourceLineNumbers, new Identifier(AccessModifier.Public, "LaunchTarget")) { Value = launchTarget, Type = WixBundleVariableType.Formatted, }); } if (!String.IsNullOrEmpty(launchTargetElevatedId)) { section.AddSymbol(new WixBundleVariableSymbol(sourceLineNumbers, new Identifier(AccessModifier.Public, "LaunchTargetElevatedId")) { Value = launchTargetElevatedId, Type = WixBundleVariableType.Formatted, }); } if (!String.IsNullOrEmpty(launchArguments)) { section.AddSymbol(new WixBundleVariableSymbol(sourceLineNumbers, new Identifier(AccessModifier.Public, "LaunchArguments")) { Value = launchArguments, Type = WixBundleVariableType.Formatted, }); } if (YesNoType.Yes == launchHidden) { section.AddSymbol(new WixBundleVariableSymbol(sourceLineNumbers, new Identifier(AccessModifier.Public, "LaunchHidden")) { Value = "yes", Type = WixBundleVariableType.Formatted, }); } if (!String.IsNullOrEmpty(launchWorkingDir)) { section.AddSymbol(new WixBundleVariableSymbol(sourceLineNumbers, new Identifier(AccessModifier.Public, "LaunchWorkingFolder")) { Value = launchWorkingDir, Type = WixBundleVariableType.Formatted, }); } if (!String.IsNullOrEmpty(licenseFile)) { section.AddSymbol(new WixVariableSymbol(sourceLineNumbers, new Identifier(AccessModifier.Public, "WixStdbaLicenseRtf")) { Value = licenseFile, }); } if (null != licenseUrl) { section.AddSymbol(new WixVariableSymbol(sourceLineNumbers, new Identifier(AccessModifier.Public, "WixStdbaLicenseUrl")) { Value = licenseUrl, }); } if (!String.IsNullOrEmpty(logoFile)) { section.AddSymbol(new WixVariableSymbol(sourceLineNumbers, new Identifier(AccessModifier.Public, "WixStdbaLogo")) { Value = logoFile, }); } if (!String.IsNullOrEmpty(logoSideFile)) { section.AddSymbol(new WixVariableSymbol(sourceLineNumbers, new Identifier(AccessModifier.Public, "WixStdbaLogoSide")) { Value = logoSideFile, }); } if (!String.IsNullOrEmpty(themeFile)) { section.AddSymbol(new WixVariableSymbol(sourceLineNumbers, new Identifier(AccessModifier.Public, "WixStdbaThemeXml")) { Value = themeFile, }); } if (!String.IsNullOrEmpty(localizationFile)) { section.AddSymbol(new WixVariableSymbol(sourceLineNumbers, new Identifier(AccessModifier.Public, "WixStdbaThemeWxl")) { Value = localizationFile, }); } if (YesNoType.Yes == suppressOptionsUI || YesNoType.Yes == suppressDowngradeFailure || YesNoType.Yes == suppressRepair || YesNoType.Yes == showVersion || YesNoType.Yes == supportCacheOnly) { var symbol = section.AddSymbol(new WixStdbaOptionsSymbol(sourceLineNumbers)); if (YesNoType.Yes == suppressOptionsUI) { symbol.SuppressOptionsUI = 1; } if (YesNoType.Yes == suppressDowngradeFailure) { symbol.SuppressDowngradeFailure = 1; } if (YesNoType.Yes == suppressRepair) { symbol.SuppressRepair = 1; } if (YesNoType.Yes == showVersion) { symbol.ShowVersion = 1; } if (YesNoType.Yes == supportCacheOnly) { symbol.SupportCacheOnly = 1; } } var baId = "WixStandardBootstrapperApplication"; switch (theme) { case WixStandardBootstrapperApplicationTheme.HyperlinkLargeLicense: baId = "WixStandardBootstrapperApplication.HyperlinkLargeLicense"; break; case WixStandardBootstrapperApplicationTheme.HyperlinkLicense: baId = "WixStandardBootstrapperApplication.HyperlinkLicense"; break; case WixStandardBootstrapperApplicationTheme.HyperlinkSidebarLicense: baId = "WixStandardBootstrapperApplication.HyperlinkSidebarLicense"; break; case WixStandardBootstrapperApplicationTheme.RtfLargeLicense: baId = "WixStandardBootstrapperApplication.RtfLargeLicense"; break; case WixStandardBootstrapperApplicationTheme.RtfLicense: baId = "WixStandardBootstrapperApplication.RtfLicense"; break; } this.CreateBARef(section, sourceLineNumbers, node, baId); } }
private void ParseHelpCollectionElement(Intermediate intermediate, IntermediateSection section, XElement element, string fileId) { var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); Identifier id = null; string description = null; string name = null; var suppressCAs = YesNoType.No; foreach (var attrib in element.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { case "Id": id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); break; case "Description": description = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "Name": name = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "SuppressCustomActions": suppressCAs = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib); break; default: this.ParseHelper.UnexpectedAttribute(element, attrib); break; } } else { this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); } } if (null == id) { id = this.ParseHelper.CreateIdentifier("vshc", fileId, description, name); } if (null == description) { this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Description")); } if (null == name) { this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Name")); } foreach (var child in element.Elements()) { if (this.Namespace == child.Name.Namespace) { switch (child.Name.LocalName) { case "HelpFileRef": this.ParseHelpFileRefElement(intermediate, section, child, id); break; case "HelpFilterRef": this.ParseHelpFilterRefElement(intermediate, section, child, id); break; case "PlugCollectionInto": this.ParsePlugCollectionIntoElement(intermediate, section, child, id); break; default: this.ParseHelper.UnexpectedElement(element, child); break; } } else { this.ParseHelper.ParseExtensionElement(this.Context.Extensions, intermediate, section, element, child); } } if (!this.Messaging.EncounteredError) { section.AddSymbol(new HelpNamespaceSymbol(sourceLineNumbers, id) { NamespaceName = name, CollectionFileRef = fileId, Description = description, }); if (YesNoType.No == suppressCAs) { this.AddReferenceToRegisterMicrosoftHelp(section, sourceLineNumbers); } } }
/// <summary> /// Parses a WixDotNetCoreBootstrapperApplication element for Bundles. /// </summary> /// <param name="node">The element to parse.</param> private void ParseWixDotNetCoreBootstrapperApplicationHostElement(Intermediate intermediate, IntermediateSection section, XElement node) { var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); string logoFile = null; string themeFile = null; string localizationFile = null; var selfContainedDeployment = YesNoType.NotSet; WixDotNetCoreBootstrapperApplicationHostTheme?theme = null; foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { case "LogoFile": logoFile = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "ThemeFile": themeFile = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "LocalizationFile": localizationFile = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "SelfContainedDeployment": selfContainedDeployment = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib); break; case "Theme": var themeValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); switch (themeValue) { case "none": theme = WixDotNetCoreBootstrapperApplicationHostTheme.None; break; case "standard": theme = WixDotNetCoreBootstrapperApplicationHostTheme.Standard; break; default: this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Theme", themeValue, "none", "standard")); theme = WixDotNetCoreBootstrapperApplicationHostTheme.Unknown; break; } break; default: this.ParseHelper.UnexpectedAttribute(node, attrib); break; } } else { this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); } } if (!theme.HasValue) { theme = WixDotNetCoreBootstrapperApplicationHostTheme.Standard; } this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); if (!this.Messaging.EncounteredError) { if (!String.IsNullOrEmpty(logoFile)) { section.AddSymbol(new WixVariableSymbol(sourceLineNumbers, new Identifier(AccessModifier.Public, "DncPreqbaLogo")) { Value = logoFile, }); } if (!String.IsNullOrEmpty(themeFile)) { section.AddSymbol(new WixVariableSymbol(sourceLineNumbers, new Identifier(AccessModifier.Public, "DncPreqbaThemeXml")) { Value = themeFile, }); } if (!String.IsNullOrEmpty(localizationFile)) { section.AddSymbol(new WixVariableSymbol(sourceLineNumbers, new Identifier(AccessModifier.Public, "DncPreqbaThemeWxl")) { Value = localizationFile, }); } if (YesNoType.Yes == selfContainedDeployment) { section.AddSymbol(new WixDncOptionsSymbol(sourceLineNumbers) { SelfContainedDeployment = 1, }); } var baId = "WixDotNetCoreBootstrapperApplicationHost"; switch (theme) { case WixDotNetCoreBootstrapperApplicationHostTheme.Standard: baId = "WixDotNetCoreBootstrapperApplicationHost.Standard"; break; } this.CreateBARef(section, sourceLineNumbers, node, baId); } }
private void ParseHelpFilterElement(Intermediate intermediate, IntermediateSection section, XElement element) { var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); Identifier id = null; string filterDefinition = null; string name = null; var suppressCAs = YesNoType.No; foreach (var attrib in element.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { case "Id": id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); break; case "FilterDefinition": filterDefinition = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "Name": name = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "SuppressCustomActions": suppressCAs = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib); break; default: this.ParseHelper.UnexpectedAttribute(element, attrib); break; } } else { this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); } } if (null == id) { id = this.ParseHelper.CreateIdentifier("hfl", name, filterDefinition); } if (null == name) { this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Name")); } this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); if (!this.Messaging.EncounteredError) { section.AddSymbol(new HelpFilterSymbol(sourceLineNumbers, id) { Description = name, QueryString = filterDefinition, }); if (YesNoType.No == suppressCAs) { this.AddReferenceToRegisterMicrosoftHelp(section, sourceLineNumbers); } } }
/// <summary> /// Parses a FirewallException element. /// </summary> /// <param name="element">The element to parse.</param> /// <param name="componentId">Identifier of the component that owns this firewall exception.</param> /// <param name="fileId">The file identifier of the parent element (null if nested under Component).</param> private void ParseFirewallExceptionElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId, string fileId) { var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); Identifier id = null; string name = null; int attributes = 0; string file = null; string program = null; string port = null; int? protocol = null; int? profile = null; string scope = null; string remoteAddresses = null; string description = null; int? direction = null; foreach (var attrib in element.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { case "Id": id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); break; case "Name": name = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "File": if (null != fileId) { this.Messaging.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, element.Name.LocalName, "File", "File")); } else { file = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); } break; case "IgnoreFailure": if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= 0x1; // feaIgnoreFailures } break; case "Program": if (null != fileId) { this.Messaging.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, element.Name.LocalName, "Program", "File")); } else { program = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); } break; case "Port": port = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "Protocol": var protocolValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); switch (protocolValue) { case "tcp": protocol = FirewallConstants.NET_FW_IP_PROTOCOL_TCP; break; case "udp": protocol = FirewallConstants.NET_FW_IP_PROTOCOL_UDP; break; default: this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, element.Name.LocalName, "Protocol", protocolValue, "tcp", "udp")); break; } break; case "Scope": scope = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); switch (scope) { case "any": remoteAddresses = "*"; break; case "localSubnet": remoteAddresses = "LocalSubnet"; break; default: this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, element.Name.LocalName, "Scope", scope, "any", "localSubnet")); break; } break; case "Profile": var profileValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); switch (profileValue) { case "domain": profile = FirewallConstants.NET_FW_PROFILE2_DOMAIN; break; case "private": profile = FirewallConstants.NET_FW_PROFILE2_PRIVATE; break; case "public": profile = FirewallConstants.NET_FW_PROFILE2_PUBLIC; break; case "all": profile = FirewallConstants.NET_FW_PROFILE2_ALL; break; default: this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, element.Name.LocalName, "Profile", profileValue, "domain", "private", "public", "all")); break; } break; case "Description": description = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "Outbound": direction = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib) == YesNoType.Yes ? FirewallConstants.NET_FW_RULE_DIR_OUT : FirewallConstants.NET_FW_RULE_DIR_IN; break; default: this.ParseHelper.UnexpectedAttribute(element, attrib); break; } } else { this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); } } // parse RemoteAddress children foreach (var child in element.Elements()) { if (this.Namespace == child.Name.Namespace) { switch (child.Name.LocalName) { case "RemoteAddress": if (null != scope) { this.Messaging.Write(FirewallErrors.IllegalRemoteAddressWithScopeAttribute(sourceLineNumbers)); } else { this.ParseRemoteAddressElement(intermediate, section, child, ref remoteAddresses); } break; default: this.ParseHelper.UnexpectedElement(element, child); break; } } else { this.ParseHelper.ParseExtensionElement(this.Context.Extensions, intermediate, section, element, child); } } if (null == id) { id = this.ParseHelper.CreateIdentifier("fex", name, remoteAddresses, componentId); } // Name is required if (null == name) { this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Name")); } // Scope or child RemoteAddress(es) are required if (null == remoteAddresses) { this.Messaging.Write(ErrorMessages.ExpectedAttributeOrElement(sourceLineNumbers, element.Name.LocalName, "Scope", "RemoteAddress")); } // can't have both Program and File if (null != program && null != file) { this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, element.Name.LocalName, "File", "Program")); } // must be nested under File, have File or Program attributes, or have Port attribute if (String.IsNullOrEmpty(fileId) && String.IsNullOrEmpty(file) && String.IsNullOrEmpty(program) && String.IsNullOrEmpty(port)) { this.Messaging.Write(FirewallErrors.NoExceptionSpecified(sourceLineNumbers)); } if (!this.Messaging.EncounteredError) { // at this point, File attribute and File parent element are treated the same if (null != file) { fileId = file; } var symbol = section.AddSymbol(new WixFirewallExceptionSymbol(sourceLineNumbers, id) { Name = name, RemoteAddresses = remoteAddresses, Profile = profile ?? FirewallConstants.NET_FW_PROFILE2_ALL, ComponentRef = componentId, Description = description, Direction = direction ?? FirewallConstants.NET_FW_RULE_DIR_IN, }); if (!String.IsNullOrEmpty(port)) { symbol.Port = port; if (!protocol.HasValue) { // default protocol is "TCP" protocol = FirewallConstants.NET_FW_IP_PROTOCOL_TCP; } } if (protocol.HasValue) { symbol.Protocol = protocol.Value; } if (!String.IsNullOrEmpty(fileId)) { symbol.Program = $"[#{fileId}]"; this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.File, fileId); } else if (!String.IsNullOrEmpty(program)) { symbol.Program = program; } if (CompilerConstants.IntegerNotSet != attributes) { symbol.Attributes = attributes; } this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4SchedFirewallExceptionsInstall", this.Context.Platform, CustomActionPlatforms.ARM64 | CustomActionPlatforms.X64 | CustomActionPlatforms.X86); this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4SchedFirewallExceptionsUninstall", this.Context.Platform, CustomActionPlatforms.ARM64 | CustomActionPlatforms.X64 | CustomActionPlatforms.X86); } }
/// <summary> /// Parses a Driver element. /// </summary> /// <param name="node">Element to parse.</param> /// <param name="componentId">Identifier for parent component.</param> private void ParseDriverElement(Intermediate intermediate, IntermediateSection section, XElement node, string componentId, bool win64) { var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); int attributes = 0; var sequence = CompilerConstants.IntegerNotSet; // check the number of times a Driver element has been nested under this Component element if (null != componentId) { if (this.components.Contains(componentId)) { this.Messaging.Write(ErrorMessages.TooManyElements(sourceLineNumbers, "Component", node.Name.LocalName, 1)); } else { this.components.Add(componentId); } } foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { case "AddRemovePrograms": if (YesNoType.No == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= 0x4; } break; case "DeleteFiles": if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= 0x10; } break; case "ForceInstall": if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= 0x1; } break; case "Legacy": if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= 0x8; } break; case "PlugAndPlayPrompt": if (YesNoType.No == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= 0x2; } break; case "Sequence": sequence = this.ParseHelper.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, int.MaxValue); 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 (!this.Messaging.EncounteredError) { switch (this.Context.Platform) { case Platform.X86: this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.CustomAction, "MsiProcessDrivers"); break; case Platform.X64: this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.CustomAction, "MsiProcessDrivers_x64"); break; } var symbol = section.AddSymbol(new MsiDriverPackagesSymbol(sourceLineNumbers) { ComponentRef = componentId, Flags = attributes, }); if (CompilerConstants.IntegerNotSet != sequence) { symbol.Sequence = sequence; } } }
/// <summary> /// Parses a SnapIn element. /// </summary> /// <param name="node">Element to parse.</param> /// <param name="fileId">Identifier for parent file.</param> /// <param name="componentId">Identifier for parent component.</param> private void ParseSnapInElement(Intermediate intermediate, IntermediateSection section, XElement node, string fileId, string componentId) { var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); string id = null; string customSnapInType = null; string description = null; string descriptionIndirect = null; var requiredPowerShellVersion = CompilerConstants.IllegalVersion; string vendor = null; string vendorIndirect = null; string version = null; foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { case "Id": id = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); break; case "CustomSnapInType": customSnapInType = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "Description": description = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "DescriptionIndirect": descriptionIndirect = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "RequiredPowerShellVersion": var ver = this.ParseHelper.GetAttributeVersionValue(sourceLineNumbers, attrib); requiredPowerShellVersion = new Version(ver); break; case "Vendor": vendor = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "VendorIndirect": vendorIndirect = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "Version": version = this.ParseHelper.GetAttributeVersionValue(sourceLineNumbers, attrib); break; default: this.ParseHelper.UnexpectedAttribute(node, attrib); break; } } else { this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); } } if (null == id) { this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); } // Default to require PowerShell 1.0. if (CompilerConstants.IllegalVersion == requiredPowerShellVersion) { requiredPowerShellVersion = new Version(1, 0); } // If the snap-in version isn't explicitly specified, get it // from the assembly version at bind time. if (null == version) { version = String.Format("!(bind.assemblyVersion.{0})", fileId); } foreach (var child in node.Elements()) { if (this.Namespace == child.Name.Namespace) { switch (child.Name.LocalName) { case "FormatsFile": this.ParseExtensionsFile(intermediate, section, child, "Formats", id, componentId); break; case "TypesFile": this.ParseExtensionsFile(intermediate, section, child, "Types", id, componentId); break; default: this.ParseHelper.UnexpectedElement(node, child); break; } } else { this.ParseHelper.ParseExtensionElement(this.Context.Extensions, intermediate, section, node, child); } } // Get the major part of the required PowerShell version which is // needed for the registry key, and put that into a WiX variable // for use in Formats and Types files. PowerShell v2 still uses 1. var major = (2 == requiredPowerShellVersion.Major) ? 1 : requiredPowerShellVersion.Major; var variableId = new Identifier(AccessModifier.Public, String.Format(CultureInfo.InvariantCulture, "{0}_{1}", VarPrefix, id)); section.AddSymbol(new WixVariableSymbol(sourceLineNumbers, variableId) { Value = major.ToString(CultureInfo.InvariantCulture), Overridable = false, }); var registryRoot = RegistryRootType.LocalMachine; // HKLM var registryKey = String.Format(CultureInfo.InvariantCulture, KeyFormat, major, id); this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "ApplicationBase", String.Format(CultureInfo.InvariantCulture, "[${0}]", componentId), componentId, false); // set the assembly name automatically when binding. // processorArchitecture is not handled correctly by PowerShell v1.0 // so format the assembly name explicitly. var assemblyName = String.Format(CultureInfo.InvariantCulture, "!(bind.assemblyName.{0}), Version=!(bind.assemblyVersion.{0}), Culture=!(bind.assemblyCulture.{0}), PublicKeyToken=!(bind.assemblyPublicKeyToken.{0})", fileId); this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "AssemblyName", assemblyName, componentId, false); if (null != customSnapInType) { this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "CustomPSSnapInType", customSnapInType, componentId, false); } if (null != description) { this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "Description", description, componentId, false); } if (null != descriptionIndirect) { this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "DescriptionIndirect", descriptionIndirect, componentId, false); } this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "ModuleName", String.Format(CultureInfo.InvariantCulture, "[#{0}]", fileId), componentId, false); this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "PowerShellVersion", requiredPowerShellVersion.ToString(2), componentId, false); if (null != vendor) { this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "Vendor", vendor, componentId, false); } if (null != vendorIndirect) { this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "VendorIndirect", vendorIndirect, componentId, false); } if (null != version) { this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "Version", version, componentId, false); } }
/// <summary> /// Parses a sql file specification element. /// </summary> /// <param name="intermediate"></param> /// <param name="section"></param> /// <param name="element">Element to parse.</param> /// <returns>Identifier of sql file specification.</returns> private Identifier ParseSqlFileSpecElement(Intermediate intermediate, IntermediateSection section, XElement element, string parentId) { var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); Identifier id = null; string fileName = null; string growthSize = null; string maxSize = null; string name = null; string size = null; foreach (var attrib in element.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { case "Id": id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); break; case "Name": name = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "Filename": fileName = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "Size": size = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "MaxSize": maxSize = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "GrowthSize": growthSize = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; default: this.ParseHelper.UnexpectedAttribute(element, attrib); break; } } else { this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); } } if (null == id) { id = this.ParseHelper.CreateIdentifier("sfs", parentId, name, fileName); } if (null == name) { this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Name")); } if (null == fileName) { this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Filename")); } this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); if (!this.Messaging.EncounteredError) { var symbol = section.AddSymbol(new SqlFileSpecSymbol(sourceLineNumbers, id) { Name = name, Filename = fileName, }); if (null != size) { symbol.Size = size; } if (null != maxSize) { symbol.MaxSize = maxSize; } if (null != growthSize) { symbol.GrowthSize = growthSize; } } return(id); }
/// <summary> /// Parses a NativeImage element. /// </summary> /// <param name="element">The element to parse.</param> /// <param name="fileId">The file identifier of the parent element.</param> private void ParseNativeImageElement(Intermediate intermediate, IntermediateSection section, XElement element, string fileId) { var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); Identifier id = null; string appBaseDirectory = null; string assemblyApplication = null; int attributes = 0x8; // 32bit is on by default int priority = 3; foreach (var attrib in element.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { case "Id": id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); break; case "AppBaseDirectory": appBaseDirectory = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); // See if a formatted value is specified. if (-1 == appBaseDirectory.IndexOf("[", StringComparison.Ordinal)) { this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.Directory, appBaseDirectory); } break; case "AssemblyApplication": assemblyApplication = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); // See if a formatted value is specified. if (-1 == assemblyApplication.IndexOf("[", StringComparison.Ordinal)) { this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.File, assemblyApplication); } break; case "Debug": if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= 0x1; } break; case "Dependencies": if (YesNoType.No == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= 0x2; } break; case "Platform": string platformValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); if (0 < platformValue.Length) { switch (platformValue) { case "32bit": // 0x8 is already on by default break; case "64bit": attributes &= ~0x8; attributes |= 0x10; break; case "all": attributes |= 0x10; break; } } break; case "Priority": priority = this.ParseHelper.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, 3); break; case "Profile": if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= 0x4; } break; default: this.ParseHelper.UnexpectedAttribute(element, attrib); break; } } else { this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); } } if (null == id) { id = this.ParseHelper.CreateIdentifier("nni", fileId); } this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4NetFxScheduleNativeImage", this.Context.Platform, CustomActionPlatforms.ARM64 | CustomActionPlatforms.X64 | CustomActionPlatforms.X86); if (!this.Messaging.EncounteredError) { section.AddSymbol(new NetFxNativeImageSymbol(sourceLineNumbers, id) { FileRef = fileId, Priority = priority, Attributes = attributes, ApplicationFileRef = assemblyApplication, ApplicationBaseDirectoryRef = appBaseDirectory, }); } }
/// <summary> /// Parses a sql database element /// </summary> /// <param name="intermediate"></param> /// <param name="section"></param> /// <param name="element">Element to parse.</param> /// <param name="componentId">Identifier for parent component.</param> private void ParseSqlDatabaseElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId) { var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); Identifier id = null; int attributes = 0; string database = null; Identifier fileSpec = null; string instance = null; Identifier logFileSpec = null; string server = null; string user = null; foreach (var attrib in element.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { case "Id": id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); break; case "ConfirmOverwrite": if (null == componentId) { this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); } if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= DbConfirmOverwrite; } break; case "ContinueOnError": if (null == componentId) { this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); } if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= DbContinueOnError; } break; case "CreateOnInstall": if (null == componentId) { this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); } if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= DbCreateOnInstall; } break; case "CreateOnReinstall": if (null == componentId) { this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); } if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= DbCreateOnReinstall; } break; case "CreateOnUninstall": if (null == componentId) { this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); } if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= DbCreateOnUninstall; } break; case "Database": database = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "DropOnInstall": if (null == componentId) { this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); } if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= DbDropOnInstall; } break; case "DropOnReinstall": if (null == componentId) { this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); } if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= DbDropOnReinstall; } break; case "DropOnUninstall": if (null == componentId) { this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); } if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= DbDropOnUninstall; } break; case "Instance": instance = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "Server": server = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "User": user = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); if (!this.ParseHelper.ContainsProperty(user)) { user = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "User", user); } break; default: this.ParseHelper.UnexpectedAttribute(element, attrib); break; } } else { this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); } } if (null == id) { id = this.ParseHelper.CreateIdentifier("sdb", componentId, server, database); } if (null == database) { this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Database")); } else if (128 < database.Length) { this.Messaging.Write(ErrorMessages.IdentifierTooLongError(sourceLineNumbers, element.Name.LocalName, "Database", database, 128)); } if (null == server) { this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Server")); } if (0 == attributes && null != componentId) { this.Messaging.Write(SqlErrors.OneOfAttributesRequiredUnderComponent(sourceLineNumbers, element.Name.LocalName, "CreateOnInstall", "CreateOnUninstall", "DropOnInstall", "DropOnUninstall")); } foreach (var child in element.Elements()) { if (this.Namespace == child.Name.Namespace) { var childSourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(child); switch (child.Name.LocalName) { case "SqlScript": if (null == componentId) { this.Messaging.Write(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); } this.ParseSqlScriptElement(intermediate, section, child, componentId, id?.Id); break; case "SqlString": if (null == componentId) { this.Messaging.Write(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); } this.ParseSqlStringElement(intermediate, section, child, componentId, id?.Id); break; case "SqlFileSpec": if (null == componentId) { this.Messaging.Write(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); } else if (null != fileSpec) { this.Messaging.Write(ErrorMessages.TooManyElements(sourceLineNumbers, element.Name.LocalName, child.Name.LocalName, 1)); } fileSpec = this.ParseSqlFileSpecElement(intermediate, section, child, id?.Id); break; case "SqlLogFileSpec": if (null == componentId) { this.Messaging.Write(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); } else if (null != logFileSpec) { this.Messaging.Write(ErrorMessages.TooManyElements(sourceLineNumbers, element.Name.LocalName, child.Name.LocalName, 1)); } logFileSpec = this.ParseSqlFileSpecElement(intermediate, section, child, id?.Id); break; default: this.ParseHelper.UnexpectedElement(element, child); break; } } else { this.ParseHelper.ParseExtensionElement(this.Context.Extensions, intermediate, section, element, child); } } if (null != componentId) { // Reference InstallSqlData and UninstallSqlData since nothing will happen without it this.AddReferenceToInstallSqlData(section, sourceLineNumbers); } if (!this.Messaging.EncounteredError) { var symbol = section.AddSymbol(new SqlDatabaseSymbol(sourceLineNumbers, id) { Server = server, Instance = instance, Database = database, ComponentRef = componentId, UserRef = user, FileSpecRef = fileSpec?.Id, LogFileSpecRef = logFileSpec?.Id, }); if (0 != attributes) { symbol.Attributes = attributes; } } }
/// <summary> /// Parses an MSMQ message queue element. /// </summary> /// <param name="node">Element to parse.</param> /// <param name="componentKey">Identifier of parent component.</param> private void ParseMessageQueueElement(Intermediate intermediate, IntermediateSection section, XElement node, string componentId) { var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); Identifier id = null; var basePriority = CompilerConstants.IntegerNotSet; var journalQuota = CompilerConstants.IntegerNotSet; string label = null; string multicastAddress = null; string pathName = null; var privLevel = CompilerConstants.IntegerNotSet; var quota = CompilerConstants.IntegerNotSet; string serviceTypeGuid = null; int attributes = 0; foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { case "Id": id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); break; case "Authenticate": if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= (int)MqiMessageQueueAttributes.Authenticate; } else { attributes &= ~(int)MqiMessageQueueAttributes.Authenticate; } break; case "BasePriority": basePriority = this.ParseHelper.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue); break; case "Journal": if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= (int)MqiMessageQueueAttributes.Journal; } else { attributes &= ~(int)MqiMessageQueueAttributes.Journal; } break; case "JournalQuota": journalQuota = this.ParseHelper.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, int.MaxValue); break; case "Label": label = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "MulticastAddress": multicastAddress = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "PathName": pathName = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "PrivLevel": var privLevelAttr = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); switch (privLevelAttr) { case "none": privLevel = (int)MqiMessageQueuePrivacyLevel.None; break; case "optional": privLevel = (int)MqiMessageQueuePrivacyLevel.Optional; break; case "body": privLevel = (int)MqiMessageQueuePrivacyLevel.Body; break; default: this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, "MessageQueue", "PrivLevel", privLevelAttr, "none", "body", "optional")); break; } break; case "Quota": quota = this.ParseHelper.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, int.MaxValue); break; case "Transactional": if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= (int)MqiMessageQueueAttributes.Transactional; } else { attributes &= ~(int)MqiMessageQueueAttributes.Transactional; } break; case "ServiceTypeGuid": serviceTypeGuid = this.TryFormatGuidValue(this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib)); break; default: this.ParseHelper.UnexpectedAttribute(node, attrib); break; } } else { this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); } } foreach (var child in node.Elements()) { if (this.Namespace == child.Name.Namespace) { switch (child.Name.LocalName) { case "MessageQueuePermission": this.ParseMessageQueuePermissionElement(intermediate, section, child, componentId, id?.Id); break; default: this.ParseHelper.UnexpectedElement(node, child); break; } } else { this.ParseHelper.ParseExtensionElement(this.Context.Extensions, intermediate, section, node, child); } } var symbol = section.AddSymbol(new MessageQueueSymbol(sourceLineNumbers, id) { ComponentRef = componentId, Label = label, MulticastAddress = multicastAddress, PathName = pathName, ServiceTypeGuid = serviceTypeGuid, Attributes = attributes, }); if (CompilerConstants.IntegerNotSet != basePriority) { symbol.BasePriority = basePriority; } if (CompilerConstants.IntegerNotSet != journalQuota) { symbol.JournalQuota = journalQuota; } if (CompilerConstants.IntegerNotSet != privLevel) { symbol.PrivLevel = privLevel; } if (CompilerConstants.IntegerNotSet != quota) { symbol.Quota = quota; } this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.CustomAction, "MessageQueuingInstall"); this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.CustomAction, "MessageQueuingUninstall"); }