From 0106f99945266b2391b18a8389d056375cfff0b0 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Tue, 8 Dec 2020 15:09:31 -0600 Subject: WIXFEAT:6209 - Move BA entry point to its own element. --- src/WixToolset.Core.Burn/Bind/BindBundleCommand.cs | 8 +- .../Bind/GenerateManifestDataFromIRCommand.cs | 1 + .../Bundles/CreateBundleExeCommand.cs | 10 +- .../Bundles/CreateNonUXContainers.cs | 10 +- src/WixToolset.Core/Compiler_Bundle.cs | 101 ++++++++++++++------- src/test/Example.Extension/Data/example.wxs | 5 +- .../TestData/BundleWithPackageGroupRef/Bundle.wxs | 5 +- .../TestData/SimpleBundle/Bundle.wxs | 15 +-- .../MultiFileBootstrapperApplication.wxs | 5 +- 9 files changed, 101 insertions(+), 59 deletions(-) (limited to 'src') diff --git a/src/WixToolset.Core.Burn/Bind/BindBundleCommand.cs b/src/WixToolset.Core.Burn/Bind/BindBundleCommand.cs index 8522eb3e..2c8231f8 100644 --- a/src/WixToolset.Core.Burn/Bind/BindBundleCommand.cs +++ b/src/WixToolset.Core.Burn/Bind/BindBundleCommand.cs @@ -101,10 +101,10 @@ namespace WixToolset.Core.Burn bundleSymbol.Attributes |= WixBundleAttributes.PerMachine; // default to per-machine but the first-per user package wil flip the bundle per-user. - // Ensure there is one and only one row in the WixBootstrapperApplication table. + // Ensure there is one and only one row in the WixBootstrapperApplicationDll table. // The compiler and linker behavior should have colluded to get // this behavior. - var bundleApplicationSymbol = this.GetSingleSymbol(); + var bundleApplicationDllSymbol = this.GetSingleSymbol(); // Ensure there is one and only one row in the WixChain table. // The compiler and linker behavior should have colluded to get @@ -440,7 +440,7 @@ namespace WixToolset.Core.Burn IEnumerable uxPayloads; IEnumerable containers; { - var command = new CreateNonUXContainers(this.BackendHelper, section, bundleApplicationSymbol, payloadSymbols, this.IntermediateFolder, layoutDirectory, this.DefaultCompressionLevel); + var command = new CreateNonUXContainers(this.BackendHelper, section, bundleApplicationDllSymbol, payloadSymbols, this.IntermediateFolder, layoutDirectory, this.DefaultCompressionLevel); command.Execute(); fileTransfers.AddRange(command.FileTransfers); @@ -475,7 +475,7 @@ namespace WixToolset.Core.Burn } { - var command = new CreateBundleExeCommand(this.Messaging, this.BackendHelper, this.IntermediateFolder, this.OutputPath, bundleApplicationSymbol, bundleSymbol, uxContainer, containers); + var command = new CreateBundleExeCommand(this.Messaging, this.BackendHelper, this.IntermediateFolder, this.OutputPath, bundleApplicationDllSymbol, bundleSymbol, uxContainer, containers); command.Execute(); fileTransfers.Add(command.Transfer); diff --git a/src/WixToolset.Core.Burn/Bind/GenerateManifestDataFromIRCommand.cs b/src/WixToolset.Core.Burn/Bind/GenerateManifestDataFromIRCommand.cs index 29768dff..24a4ae67 100644 --- a/src/WixToolset.Core.Burn/Bind/GenerateManifestDataFromIRCommand.cs +++ b/src/WixToolset.Core.Burn/Bind/GenerateManifestDataFromIRCommand.cs @@ -61,6 +61,7 @@ namespace WixToolset.Core.Burn.Bind case SymbolDefinitionType.ProvidesDependency: case SymbolDefinitionType.WixApprovedExeForElevation: case SymbolDefinitionType.WixBootstrapperApplication: + case SymbolDefinitionType.WixBootstrapperApplicationDll: case SymbolDefinitionType.WixBundle: case SymbolDefinitionType.WixBundleCatalog: case SymbolDefinitionType.WixBundleContainer: diff --git a/src/WixToolset.Core.Burn/Bundles/CreateBundleExeCommand.cs b/src/WixToolset.Core.Burn/Bundles/CreateBundleExeCommand.cs index 0355cdc6..576ac348 100644 --- a/src/WixToolset.Core.Burn/Bundles/CreateBundleExeCommand.cs +++ b/src/WixToolset.Core.Burn/Bundles/CreateBundleExeCommand.cs @@ -17,13 +17,13 @@ namespace WixToolset.Core.Burn.Bundles internal class CreateBundleExeCommand { - public CreateBundleExeCommand(IMessaging messaging, IBackendHelper backendHelper, string intermediateFolder, string outputPath, WixBootstrapperApplicationSymbol bootstrapperApplicationSymbol, WixBundleSymbol bundleSymbol, WixBundleContainerSymbol uxContainer, IEnumerable containers) + public CreateBundleExeCommand(IMessaging messaging, IBackendHelper backendHelper, string intermediateFolder, string outputPath, WixBootstrapperApplicationDllSymbol bootstrapperApplicationDllSymbol, WixBundleSymbol bundleSymbol, WixBundleContainerSymbol uxContainer, IEnumerable containers) { this.Messaging = messaging; this.BackendHelper = backendHelper; this.IntermediateFolder = intermediateFolder; this.OutputPath = outputPath; - this.BootstrapperApplicationSymbol = bootstrapperApplicationSymbol; + this.BootstrapperApplicationDllSymbol = bootstrapperApplicationDllSymbol; this.BundleSymbol = bundleSymbol; this.UXContainer = uxContainer; this.Containers = containers; @@ -39,7 +39,7 @@ namespace WixToolset.Core.Burn.Bundles private string OutputPath { get; } - private WixBootstrapperApplicationSymbol BootstrapperApplicationSymbol { get; } + private WixBootstrapperApplicationDllSymbol BootstrapperApplicationDllSymbol { get; } private WixBundleSymbol BundleSymbol { get; } @@ -72,7 +72,7 @@ namespace WixToolset.Core.Burn.Bundles var windowsAssemblyVersion = GetWindowsAssemblyVersion(this.BundleSymbol); - var applicationManifestData = GenerateApplicationManifest(this.BundleSymbol, this.BootstrapperApplicationSymbol, this.OutputPath, windowsAssemblyVersion); + var applicationManifestData = GenerateApplicationManifest(this.BundleSymbol, this.BootstrapperApplicationDllSymbol, this.OutputPath, windowsAssemblyVersion); UpdateBurnResources(bundleTempPath, this.OutputPath, this.BundleSymbol, windowsAssemblyVersion, applicationManifestData); @@ -101,7 +101,7 @@ namespace WixToolset.Core.Burn.Bundles } } - private static byte[] GenerateApplicationManifest(WixBundleSymbol bundleSymbol, WixBootstrapperApplicationSymbol bootstrapperApplicationSymbol, string outputPath, Version windowsAssemblyVersion) + private static byte[] GenerateApplicationManifest(WixBundleSymbol bundleSymbol, WixBootstrapperApplicationDllSymbol bootstrapperApplicationSymbol, string outputPath, Version windowsAssemblyVersion) { const string asmv1Namespace = "urn:schemas-microsoft-com:asm.v1"; const string asmv3Namespace = "urn:schemas-microsoft-com:asm.v3"; diff --git a/src/WixToolset.Core.Burn/Bundles/CreateNonUXContainers.cs b/src/WixToolset.Core.Burn/Bundles/CreateNonUXContainers.cs index 3e54013a..0dd2ba15 100644 --- a/src/WixToolset.Core.Burn/Bundles/CreateNonUXContainers.cs +++ b/src/WixToolset.Core.Burn/Bundles/CreateNonUXContainers.cs @@ -14,11 +14,11 @@ namespace WixToolset.Core.Burn.Bundles internal class CreateNonUXContainers { - public CreateNonUXContainers(IBackendHelper backendHelper, IntermediateSection section, WixBootstrapperApplicationSymbol bootstrapperApplicationSymbol, Dictionary payloadSymbols, string intermediateFolder, string layoutFolder, CompressionLevel? defaultCompressionLevel) + public CreateNonUXContainers(IBackendHelper backendHelper, IntermediateSection section, WixBootstrapperApplicationDllSymbol bootstrapperApplicationDllSymbol, Dictionary payloadSymbols, string intermediateFolder, string layoutFolder, CompressionLevel? defaultCompressionLevel) { this.BackendHelper = backendHelper; this.Section = section; - this.BootstrapperApplicationSymbol = bootstrapperApplicationSymbol; + this.BootstrapperApplicationDllSymbol = bootstrapperApplicationDllSymbol; this.PayloadSymbols = payloadSymbols; this.IntermediateFolder = intermediateFolder; this.LayoutFolder = layoutFolder; @@ -39,7 +39,7 @@ namespace WixToolset.Core.Burn.Bundles private IntermediateSection Section { get; } - private WixBootstrapperApplicationSymbol BootstrapperApplicationSymbol { get; } + private WixBootstrapperApplicationDllSymbol BootstrapperApplicationDllSymbol { get; } private Dictionary PayloadSymbols { get; } @@ -81,9 +81,9 @@ namespace WixToolset.Core.Burn.Bundles container.WorkingPath = Path.Combine(this.IntermediateFolder, container.Name); container.AttachedContainerIndex = 0; - // Gather the list of UX payloads but ensure the BootstrapperApplication Payload is the first + // Gather the list of UX payloads but ensure the BootstrapperApplicationDll Payload is the first // in the list since that is the Payload that Burn attempts to load. - var baPayloadId = this.BootstrapperApplicationSymbol.Id.Id; + var baPayloadId = this.BootstrapperApplicationDllSymbol.Id.Id; foreach (var uxPayload in containerPayloads) { diff --git a/src/WixToolset.Core/Compiler_Bundle.cs b/src/WixToolset.Core/Compiler_Bundle.cs index 68b738fb..00f88c1f 100644 --- a/src/WixToolset.Core/Compiler_Bundle.cs +++ b/src/WixToolset.Core/Compiler_Bundle.cs @@ -647,18 +647,73 @@ namespace WixToolset.Core private void ParseBootstrapperApplicationElement(XElement node) { var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + Identifier id = null; Identifier previousId = null; var previousType = ComplexReferenceChildType.Unknown; - var dpiAwareness = WixBootstrapperApplicationDpiAwarenessType.PerMonitorV2; - // The BootstrapperApplication element acts like a Payload element so delegate to the "Payload" attribute parsing code to parse and create a Payload entry. - var hasSourceFile = this.ParsePayloadElementContent(node, ComplexReferenceParentType.Container, Compiler.BurnUXContainerId, previousType, previousId, false, out var id); - if (hasSourceFile) + foreach (var attrib in node.Attributes()) { - previousId = id; - previousType = ComplexReferenceChildType.Payload; + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) + { + switch (attrib.Name.LocalName) + { + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; + } + } } + foreach (var child in node.Elements()) + { + if (CompilerCore.WixNamespace == child.Name.Namespace) + { + switch (child.Name.LocalName) + { + case "BootstrapperApplicationDll": + previousId = this.ParseBootstrapperApplicationDllElement(child, previousType, previousId); + previousType = ComplexReferenceChildType.Payload; + break; + case "Payload": + previousId = this.ParsePayloadElement(child, ComplexReferenceParentType.Container, Compiler.BurnUXContainerId, previousType, previousId); + previousType = ComplexReferenceChildType.Payload; + break; + case "PayloadGroupRef": + previousId = this.ParsePayloadGroupRefElement(child, ComplexReferenceParentType.Container, Compiler.BurnUXContainerId, previousType, previousId); + previousType = ComplexReferenceChildType.PayloadGroup; + break; + default: + this.Core.UnexpectedElement(node, child); + break; + } + } + else + { + this.Core.ParseExtensionElement(node, child); + } + } + + if (id != null) + { + this.Core.AddSymbol(new WixBootstrapperApplicationSymbol(sourceLineNumbers, id)); + } + } + + /// + /// Parse the BoostrapperApplication element. + /// + /// Element to parse + private Identifier ParseBootstrapperApplicationDllElement(XElement node, ComplexReferenceChildType previousType, Identifier previousId) + { + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var dpiAwareness = WixBootstrapperApplicationDpiAwarenessType.PerMonitorV2; + + // The BootstrapperApplicationDll element acts like a Payload element so delegate to the "Payload" attribute parsing code to parse and create a Payload entry. + this.ParsePayloadElementContent(node, ComplexReferenceParentType.Container, Compiler.BurnUXContainerId, previousType, previousId, true, out var id); + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) @@ -699,17 +754,9 @@ namespace WixToolset.Core { switch (child.Name.LocalName) { - case "Payload": - previousId = this.ParsePayloadElement(child, ComplexReferenceParentType.Container, Compiler.BurnUXContainerId, previousType, previousId); - previousType = ComplexReferenceChildType.Payload; - break; - case "PayloadGroupRef": - previousId = this.ParsePayloadGroupRefElement(child, ComplexReferenceParentType.Container, Compiler.BurnUXContainerId, previousType, previousId); - previousType = ComplexReferenceChildType.PayloadGroup; - break; - default: - this.Core.UnexpectedElement(node, child); - break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -718,15 +765,6 @@ namespace WixToolset.Core } } - if (null == previousId) - { - // We need *either* or or even just @SourceFile on the BA... - // but we just say there's a missing . - // TODO: Is there a better message for this? - this.Core.Write(ErrorMessages.ExpectedElement(sourceLineNumbers, node.Name.LocalName, "Payload")); - } - - // Add the application as an attached container and if a SourceFile was provided add the Id as the BA. if (!this.Core.EncounteredError) { this.Core.AddSymbol(new WixBundleContainerSymbol(sourceLineNumbers, Compiler.BurnUXContainerId) @@ -735,14 +773,13 @@ namespace WixToolset.Core Type = ContainerType.Attached }); - if (hasSourceFile) + this.Core.AddSymbol(new WixBootstrapperApplicationDllSymbol(sourceLineNumbers, id) { - this.Core.AddSymbol(new WixBootstrapperApplicationSymbol(sourceLineNumbers, id) - { - DpiAwareness = dpiAwareness, - }); - } + DpiAwareness = dpiAwareness, + }); } + + return id; } /// diff --git a/src/test/Example.Extension/Data/example.wxs b/src/test/Example.Extension/Data/example.wxs index cd17d478..af5d5086 100644 --- a/src/test/Example.Extension/Data/example.wxs +++ b/src/test/Example.Extension/Data/example.wxs @@ -1,4 +1,3 @@ - @@ -6,7 +5,9 @@ - + + + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/BundleWithPackageGroupRef/Bundle.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/BundleWithPackageGroupRef/Bundle.wxs index 207a8de1..e738b407 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/BundleWithPackageGroupRef/Bundle.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/BundleWithPackageGroupRef/Bundle.wxs @@ -1,7 +1,8 @@ - - + + + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleBundle/Bundle.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleBundle/Bundle.wxs index 7ef1fc05..21749c07 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleBundle/Bundle.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleBundle/Bundle.wxs @@ -1,11 +1,12 @@ - - - - - - - + + + + + + + + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleBundle/MultiFileBootstrapperApplication.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleBundle/MultiFileBootstrapperApplication.wxs index 88c4cf1b..f5fe9885 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleBundle/MultiFileBootstrapperApplication.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleBundle/MultiFileBootstrapperApplication.wxs @@ -1,6 +1,7 @@ - - + + + -- cgit v1.2.3-55-g6feb