diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2021-04-24 15:34:08 -0500 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2021-04-25 23:06:35 -0500 |
| commit | 23de0a19bffe457916b0a45e07044650ace8f456 (patch) | |
| tree | 73af8c33f0814fb91e9c8eed0f844716e3455a58 /src/WixToolset.Core/Link/FlattenAndProcessBundleTablesCommand.cs | |
| parent | e1e1af1d3940e983bc727bf91a0952840171a279 (diff) | |
| download | wix-23de0a19bffe457916b0a45e07044650ace8f456.tar.gz wix-23de0a19bffe457916b0a45e07044650ace8f456.tar.bz2 wix-23de0a19bffe457916b0a45e07044650ace8f456.zip | |
Assign authored payloads to authored containers during linking.
Diffstat (limited to 'src/WixToolset.Core/Link/FlattenAndProcessBundleTablesCommand.cs')
| -rw-r--r-- | src/WixToolset.Core/Link/FlattenAndProcessBundleTablesCommand.cs | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/src/WixToolset.Core/Link/FlattenAndProcessBundleTablesCommand.cs b/src/WixToolset.Core/Link/FlattenAndProcessBundleTablesCommand.cs new file mode 100644 index 00000000..0fa48d8c --- /dev/null +++ b/src/WixToolset.Core/Link/FlattenAndProcessBundleTablesCommand.cs | |||
| @@ -0,0 +1,91 @@ | |||
| 1 | // 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. | ||
| 2 | |||
| 3 | namespace WixToolset.Core.Link | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.Collections.Generic; | ||
| 7 | using System.Linq; | ||
| 8 | using WixToolset.Data; | ||
| 9 | using WixToolset.Data.Burn; | ||
| 10 | using WixToolset.Data.Symbols; | ||
| 11 | using WixToolset.Extensibility.Services; | ||
| 12 | |||
| 13 | internal class FlattenAndProcessBundleTablesCommand | ||
| 14 | { | ||
| 15 | public FlattenAndProcessBundleTablesCommand(IntermediateSection entrySection, IMessaging messaging) | ||
| 16 | { | ||
| 17 | this.EntrySection = entrySection; | ||
| 18 | this.Messaging = messaging; | ||
| 19 | } | ||
| 20 | |||
| 21 | private IntermediateSection EntrySection { get; } | ||
| 22 | |||
| 23 | private IMessaging Messaging { get; } | ||
| 24 | |||
| 25 | public void Execute() | ||
| 26 | { | ||
| 27 | this.FlattenBundleTables(); | ||
| 28 | |||
| 29 | if (this.Messaging.EncounteredError) | ||
| 30 | { | ||
| 31 | return; | ||
| 32 | } | ||
| 33 | |||
| 34 | this.ProcessBundleComplexReferences(); | ||
| 35 | } | ||
| 36 | |||
| 37 | /// <summary> | ||
| 38 | /// Flattens the tables used in a Bundle. | ||
| 39 | /// </summary> | ||
| 40 | private void FlattenBundleTables() | ||
| 41 | { | ||
| 42 | // We need to flatten the nested PayloadGroups and PackageGroups under | ||
| 43 | // UX, Chain, and any Containers. When we're done, the WixGroups table | ||
| 44 | // will hold Payloads under UX, ChainPackages (references?) under Chain, | ||
| 45 | // and ChainPackages/Payloads under the attached and any detatched | ||
| 46 | // Containers. | ||
| 47 | var groups = new WixGroupingOrdering(this.EntrySection, this.Messaging); | ||
| 48 | |||
| 49 | // Create UX payloads and Package payloads | ||
| 50 | groups.UseTypes(new[] { ComplexReferenceParentType.Container, ComplexReferenceParentType.Layout, ComplexReferenceParentType.PackageGroup, ComplexReferenceParentType.PayloadGroup, ComplexReferenceParentType.Package }, | ||
| 51 | new[] { ComplexReferenceChildType.PackageGroup, ComplexReferenceChildType.Package, ComplexReferenceChildType.PackagePayload, ComplexReferenceChildType.PayloadGroup, ComplexReferenceChildType.Payload }); | ||
| 52 | groups.FlattenAndRewriteGroups(ComplexReferenceParentType.Package, false); | ||
| 53 | groups.FlattenAndRewriteGroups(ComplexReferenceParentType.Container, false); | ||
| 54 | groups.FlattenAndRewriteGroups(ComplexReferenceParentType.Layout, false); | ||
| 55 | |||
| 56 | // Create Chain packages... | ||
| 57 | groups.UseTypes(new[] { ComplexReferenceParentType.PackageGroup }, new[] { ComplexReferenceChildType.Package, ComplexReferenceChildType.PackageGroup }); | ||
| 58 | groups.FlattenAndRewriteRows(ComplexReferenceChildType.PackageGroup, "WixChain", false); | ||
| 59 | |||
| 60 | groups.RemoveUsedGroupRows(); | ||
| 61 | } | ||
| 62 | |||
| 63 | private void ProcessBundleComplexReferences() | ||
| 64 | { | ||
| 65 | var groups = this.EntrySection.Symbols.OfType<WixGroupSymbol>().ToList(); | ||
| 66 | var payloadsById = this.EntrySection.Symbols.OfType<WixBundlePayloadSymbol>().ToDictionary(c => c.Id.Id); | ||
| 67 | |||
| 68 | // Assign authored payloads to authored containers. | ||
| 69 | // Compressed Payloads not assigned to a container here will get assigned to the default attached container during binding. | ||
| 70 | foreach (var groupSymbol in groups) | ||
| 71 | { | ||
| 72 | if (ComplexReferenceChildType.Payload == groupSymbol.ChildType) | ||
| 73 | { | ||
| 74 | var payloadSymbol = payloadsById[groupSymbol.ChildId]; | ||
| 75 | |||
| 76 | if (ComplexReferenceParentType.Container == groupSymbol.ParentType) | ||
| 77 | { | ||
| 78 | // TODO: v3 didn't warn if we overwrote the payload's container. | ||
| 79 | // Should we warn now? | ||
| 80 | payloadSymbol.ContainerRef = groupSymbol.ParentId; | ||
| 81 | } | ||
| 82 | else if (ComplexReferenceParentType.Layout == groupSymbol.ParentType) | ||
| 83 | { | ||
| 84 | payloadSymbol.LayoutOnly = true; | ||
| 85 | } | ||
| 86 | } | ||
| 87 | } | ||
| 88 | |||
| 89 | } | ||
| 90 | } | ||
| 91 | } | ||
