From 704139b787d2016e43b6a87dbfc41555dac8326a Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sat, 2 Feb 2019 17:01:09 -0600 Subject: Integrate into latest v4. --- src/wixext/DifxAppCompiler.cs | 66 +++++++++++++--------- src/wixext/DifxAppDecompiler.cs | 4 +- src/wixext/DifxAppExtensionData.cs | 36 +++--------- src/wixext/DifxAppExtensionFactory.cs | 18 ++++++ ...ifxAppWindowsInstallerBackendBinderExtension.cs | 26 +++++++++ src/wixext/Tuples/DifxAppTupleDefinitions.cs | 39 +++++++++++++ src/wixext/Tuples/MsiDriverPackagesTuple.cs | 63 +++++++++++++++++++++ src/wixext/WixDifxAppExtension.csproj | 47 --------------- src/wixext/WixToolset.DifxApp.wixext.csproj | 30 ++++++++++ src/wixext/WixToolset.DifxApp.wixext.targets | 11 ++++ 10 files changed, 238 insertions(+), 102 deletions(-) create mode 100644 src/wixext/DifxAppExtensionFactory.cs create mode 100644 src/wixext/DifxAppWindowsInstallerBackendBinderExtension.cs create mode 100644 src/wixext/Tuples/DifxAppTupleDefinitions.cs create mode 100644 src/wixext/Tuples/MsiDriverPackagesTuple.cs delete mode 100644 src/wixext/WixDifxAppExtension.csproj create mode 100644 src/wixext/WixToolset.DifxApp.wixext.csproj create mode 100644 src/wixext/WixToolset.DifxApp.wixext.targets (limited to 'src/wixext') diff --git a/src/wixext/DifxAppCompiler.cs b/src/wixext/DifxAppCompiler.cs index 63396932..98f36b3f 100644 --- a/src/wixext/DifxAppCompiler.cs +++ b/src/wixext/DifxAppCompiler.cs @@ -1,26 +1,27 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -namespace WixToolset.Extensions +namespace WixToolset.DifxApp { using System; using System.Collections.Generic; using System.Xml.Linq; using WixToolset.Data; + using WixToolset.DifxApp.Tuples; using WixToolset.Extensibility; /// /// The compiler for the WiX Toolset Driver Install Frameworks for Applications Extension. /// - public sealed class DifxAppCompiler : CompilerExtension + public sealed class DifxAppCompiler : BaseCompilerExtension { private HashSet components; + public override XNamespace Namespace => "http://wixtoolset.org/schemas/v4/wxs/difxapp"; /// /// Instantiate a new DifxAppCompiler. /// public DifxAppCompiler() { - this.Namespace = "http://wixtoolset.org/schemas/v4/wxs/difxapp"; this.components = new HashSet(); } @@ -31,26 +32,27 @@ namespace WixToolset.Extensions /// Parent element of element to process. /// Element to process. /// Extra information about the context in which this element is being parsed. - public override void ParseElement(XElement parentElement, XElement element, IDictionary context) + public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context) { switch (parentElement.Name.LocalName) { case "Component": string componentId = context["ComponentId"]; string directoryId = context["DirectoryId"]; + bool componentWin64 = Boolean.Parse(context["Win64"]); switch (element.Name.LocalName) { case "Driver": - this.ParseDriverElement(element, componentId); + this.ParseDriverElement(intermediate, section, element, componentId, componentWin64); break; default: - this.Core.UnexpectedElement(parentElement, element); + this.ParseHelper.UnexpectedElement(parentElement, element); break; } break; default: - this.Core.UnexpectedElement(parentElement, element); + this.ParseHelper.UnexpectedElement(parentElement, element); break; } } @@ -60,9 +62,9 @@ namespace WixToolset.Extensions /// /// Element to parse. /// Identifier for parent component. - private void ParseDriverElement(XElement node, string componentId) + private void ParseDriverElement(Intermediate intermediate, IntermediateSection section, XElement node, string componentId, bool win64) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); int attributes = 0; int sequence = CompilerConstants.IntegerNotSet; @@ -71,7 +73,7 @@ namespace WixToolset.Extensions { if (this.components.Contains(componentId)) { - this.Core.OnMessage(WixErrors.TooManyElements(sourceLineNumbers, "Component", node.Name.LocalName, 1)); + this.Messaging.Write(ErrorMessages.TooManyElements(sourceLineNumbers, "Component", node.Name.LocalName, 1)); } else { @@ -86,62 +88,74 @@ namespace WixToolset.Extensions switch (attrib.Name.LocalName) { case "AddRemovePrograms": - if (YesNoType.No == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + if (YesNoType.No == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= 0x4; } break; case "DeleteFiles": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= 0x10; } break; case "ForceInstall": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= 0x1; } break; case "Legacy": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= 0x8; } break; case "PlugAndPlayPrompt": - if (YesNoType.No == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + if (YesNoType.No == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= 0x2; } break; case "Sequence": - sequence = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, int.MaxValue); + sequence = this.ParseHelper.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, int.MaxValue); break; default: - this.Core.UnexpectedAttribute(node, attrib); + this.ParseHelper.UnexpectedAttribute(node, attrib); break; } } else { - this.Core.ParseExtensionAttribute(node, attrib); + this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); } } - this.Core.ParseForExtensionElements(node); + this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); - if (!this.Core.EncounteredError) + if (!this.Messaging.EncounteredError) { - Row row = this.Core.CreateRow(sourceLineNumbers, "MsiDriverPackages"); - row[0] = componentId; - row[1] = attributes; - if (CompilerConstants.IntegerNotSet != sequence) + switch (this.Context.Platform) { - row[2] = sequence; + case Platform.X86: + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "MsiProcessDrivers"); + break; + case Platform.X64: + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "MsiProcessDrivers_x64"); + break; + case Platform.IA64: + case Platform.ARM: + this.Messaging.Write(ErrorMessages.UnsupportedPlatformForElement(sourceLineNumbers, this.Context.Platform.ToString(), node.Name.LocalName)); + break; } - this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "MsiProcessDrivers"); + var row = (MsiDriverPackagesTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "MsiDriverPackages"); + row.Set(0, componentId); + row.Set(1, attributes); + if (CompilerConstants.IntegerNotSet != sequence) + { + row.Set(2, sequence); + } } } } diff --git a/src/wixext/DifxAppDecompiler.cs b/src/wixext/DifxAppDecompiler.cs index db42b3d0..e41d8b98 100644 --- a/src/wixext/DifxAppDecompiler.cs +++ b/src/wixext/DifxAppDecompiler.cs @@ -1,7 +1,8 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -namespace WixToolset.Extensions +namespace WixToolset.DifxApp { +#if TODO_CONSIDER_DECOMPILER using System; using System.Collections; using System.Globalization; @@ -93,4 +94,5 @@ namespace WixToolset.Extensions } } } +#endif } diff --git a/src/wixext/DifxAppExtensionData.cs b/src/wixext/DifxAppExtensionData.cs index 266f5ee4..49e1354f 100644 --- a/src/wixext/DifxAppExtensionData.cs +++ b/src/wixext/DifxAppExtensionData.cs @@ -1,43 +1,23 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -namespace WixToolset.Extensions +namespace WixToolset.DifxApp { - using System; - using System.Reflection; using WixToolset.Data; using WixToolset.Extensibility; - /// - /// The WiX Toolset Driver Install Frameworks for Applications Extension. - /// - public sealed class DifxAppExtensionData : ExtensionData + public sealed class DifxAppExtensionData : BaseExtensionData { - private static TableDefinitionCollection tableDefinitions; + public override string DefaultCulture => "en-US"; - /// - /// Gets the optional table definitions for this extension. - /// - /// The optional table definitions for this extension. - public override TableDefinitionCollection TableDefinitions + public override bool TryGetTupleDefinitionByName(string name, out IntermediateTupleDefinition tupleDefinition) { - get - { - return DifxAppExtensionData.GetExtensionTableDefinitions(); - } + tupleDefinition = DifxAppTupleDefinitions.ByName(name); + return tupleDefinition != null; } - /// - /// Internal mechanism to access the extension's table definitions. - /// - /// Extension's table definitions. - internal static TableDefinitionCollection GetExtensionTableDefinitions() + public override Intermediate GetLibrary(ITupleDefinitionCreator tupleDefinitions) { - if (null == DifxAppExtensionData.tableDefinitions) - { - DifxAppExtensionData.tableDefinitions = ExtensionData.LoadTableDefinitionHelper(Assembly.GetExecutingAssembly(), "WixToolset.Extensions.Data.tables.xml"); - } - - return DifxAppExtensionData.tableDefinitions; + return Intermediate.Load(typeof(DifxAppExtensionData).Assembly, "WixToolset.DifxApp.difxapp.wixlib", tupleDefinitions); } } } diff --git a/src/wixext/DifxAppExtensionFactory.cs b/src/wixext/DifxAppExtensionFactory.cs new file mode 100644 index 00000000..4565ce17 --- /dev/null +++ b/src/wixext/DifxAppExtensionFactory.cs @@ -0,0 +1,18 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.DifxApp +{ + using System; + using System.Collections.Generic; + using WixToolset.Extensibility; + + public class DifxAppExtensionFactory : BaseExtensionFactory + { + protected override IEnumerable ExtensionTypes => new[] + { + typeof(DifxAppCompiler), + typeof(DifxAppExtensionData), + typeof(DifxAppWindowsInstallerBackendBinderExtension), + }; + } +} diff --git a/src/wixext/DifxAppWindowsInstallerBackendBinderExtension.cs b/src/wixext/DifxAppWindowsInstallerBackendBinderExtension.cs new file mode 100644 index 00000000..4d81c134 --- /dev/null +++ b/src/wixext/DifxAppWindowsInstallerBackendBinderExtension.cs @@ -0,0 +1,26 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.DifxApp +{ + using System.Linq; + using System.Xml; + using WixToolset.Data.WindowsInstaller; + using WixToolset.Extensibility; + + public class DifxAppWindowsInstallerBackendBinderExtension : BaseWindowsInstallerBackendBinderExtension + { + private static readonly TableDefinition[] Tables = LoadTables(); + + protected override TableDefinition[] TableDefinitionsForTuples => Tables; + + private static TableDefinition[] LoadTables() + { + using (var resourceStream = typeof(DifxAppWindowsInstallerBackendBinderExtension).Assembly.GetManifestResourceStream("WixToolset.DifxApp.tables.xml")) + using (var reader = XmlReader.Create(resourceStream)) + { + var tables = TableDefinitionCollection.Load(reader); + return tables.ToArray(); + } + } + } +} diff --git a/src/wixext/Tuples/DifxAppTupleDefinitions.cs b/src/wixext/Tuples/DifxAppTupleDefinitions.cs new file mode 100644 index 00000000..37dabb86 --- /dev/null +++ b/src/wixext/Tuples/DifxAppTupleDefinitions.cs @@ -0,0 +1,39 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.DifxApp +{ + using System; + using WixToolset.Data; + + public enum DifxAppTupleDefinitionType + { + MsiDriverPackages, + } + + public static partial class DifxAppTupleDefinitions + { + public static readonly Version Version = new Version("4.0.0"); + + public static IntermediateTupleDefinition ByName(string name) + { + if (!Enum.TryParse(name, out DifxAppTupleDefinitionType type)) + { + return null; + } + + return ByType(type); + } + + public static IntermediateTupleDefinition ByType(DifxAppTupleDefinitionType type) + { + switch (type) + { + case DifxAppTupleDefinitionType.MsiDriverPackages: + return DifxAppTupleDefinitions.MsiDriverPackages; + + default: + throw new ArgumentOutOfRangeException(nameof(type)); + } + } + } +} diff --git a/src/wixext/Tuples/MsiDriverPackagesTuple.cs b/src/wixext/Tuples/MsiDriverPackagesTuple.cs new file mode 100644 index 00000000..aecc7e77 --- /dev/null +++ b/src/wixext/Tuples/MsiDriverPackagesTuple.cs @@ -0,0 +1,63 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.DifxApp +{ + using WixToolset.Data; + using WixToolset.DifxApp.Tuples; + + public static partial class DifxAppTupleDefinitions + { + public static readonly IntermediateTupleDefinition MsiDriverPackages = new IntermediateTupleDefinition( + DifxAppTupleDefinitionType.MsiDriverPackages.ToString(), + new[] + { + new IntermediateFieldDefinition(nameof(MsiDriverPackagesTupleFields.Component), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(MsiDriverPackagesTupleFields.Flags), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(MsiDriverPackagesTupleFields.Sequence), IntermediateFieldType.Number), + }, + typeof(MsiDriverPackagesTuple)); + } +} + +namespace WixToolset.DifxApp.Tuples +{ + using WixToolset.Data; + + public enum MsiDriverPackagesTupleFields + { + Component, + Flags, + Sequence, + } + + public class MsiDriverPackagesTuple : IntermediateTuple + { + public MsiDriverPackagesTuple() : base(DifxAppTupleDefinitions.MsiDriverPackages, null, null) + { + } + + public MsiDriverPackagesTuple(SourceLineNumber sourceLineNumber, Identifier id = null) : base(DifxAppTupleDefinitions.MsiDriverPackages, sourceLineNumber, id) + { + } + + public IntermediateField this[MsiDriverPackagesTupleFields index] => this.Fields[(int)index]; + + public string Component + { + get => this.Fields[(int)MsiDriverPackagesTupleFields.Component].AsString(); + set => this.Set((int)MsiDriverPackagesTupleFields.Component, value); + } + + public int Flags + { + get => this.Fields[(int)MsiDriverPackagesTupleFields.Flags].AsNumber(); + set => this.Set((int)MsiDriverPackagesTupleFields.Flags, value); + } + + public int Sequence + { + get => this.Fields[(int)MsiDriverPackagesTupleFields.Sequence].AsNumber(); + set => this.Set((int)MsiDriverPackagesTupleFields.Sequence, value); + } + } +} \ No newline at end of file diff --git a/src/wixext/WixDifxAppExtension.csproj b/src/wixext/WixDifxAppExtension.csproj deleted file mode 100644 index 5e85c675..00000000 --- a/src/wixext/WixDifxAppExtension.csproj +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - {2256EFD7-E678-4485-818D-986D590068BE} - WixDifxAppExtension - Library - WixToolset.Extensions - - - - - - - - $(RootNamespace).Data.tables.xml - - - $(RootNamespace).Xsd.difxapp.xsd - PreserveNewest - - - Designer - WixToolset.Data.Serialize - WixToolset.Extensions.Serialize.DifxApp - - - - - - - - - - - Platform=x86 - false - - - Platform=x64 - false - - - - diff --git a/src/wixext/WixToolset.DifxApp.wixext.csproj b/src/wixext/WixToolset.DifxApp.wixext.csproj new file mode 100644 index 00000000..5717b42a --- /dev/null +++ b/src/wixext/WixToolset.DifxApp.wixext.csproj @@ -0,0 +1,30 @@ + + + + + + netstandard2.0 + WixToolset.DifxApp + WiX Toolset DIFxApp Extension + WiX Toolset DIFxApp Extension + true + build + + + + + + + + + + + + + + + + + + + diff --git a/src/wixext/WixToolset.DifxApp.wixext.targets b/src/wixext/WixToolset.DifxApp.wixext.targets new file mode 100644 index 00000000..b01d4116 --- /dev/null +++ b/src/wixext/WixToolset.DifxApp.wixext.targets @@ -0,0 +1,11 @@ + + + + + + $(MSBuildThisFileDirectory)..\tools\WixToolset.DifxApp.wixext.dll + + + + + -- cgit v1.2.3-55-g6feb