aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Core')
-rw-r--r--src/WixToolset.Core/CompilerErrors.cs2
-rw-r--r--src/WixToolset.Core/CompilerWarnings.cs2
-rw-r--r--src/WixToolset.Core/Compiler_Bundle.cs1
-rw-r--r--src/WixToolset.Core/Link/FlattenAndProcessBundleTablesCommand.cs121
-rw-r--r--src/WixToolset.Core/Link/WixGroupingOrdering.cs11
-rw-r--r--src/WixToolset.Core/LinkerErrors.cs48
-rw-r--r--src/WixToolset.Core/LinkerWarnings.cs30
-rw-r--r--src/WixToolset.Core/WixToolset.Core.csproj12
8 files changed, 206 insertions, 21 deletions
diff --git a/src/WixToolset.Core/CompilerErrors.cs b/src/WixToolset.Core/CompilerErrors.cs
index 9b3d85b9..10646dfd 100644
--- a/src/WixToolset.Core/CompilerErrors.cs
+++ b/src/WixToolset.Core/CompilerErrors.cs
@@ -38,6 +38,6 @@ namespace WixToolset.Core
38 38
39 IllegalName = 6601, 39 IllegalName = 6601,
40 ExampleRegid = 6602, 40 ExampleRegid = 6602,
41 } 41 } // 5400-5499 and 6600-6699 were the ranges for Dependency and Tag which are now in Core between CompilerWarnings and CompilerErrors.
42 } 42 }
43} 43}
diff --git a/src/WixToolset.Core/CompilerWarnings.cs b/src/WixToolset.Core/CompilerWarnings.cs
index eb838ae2..5c11b878 100644
--- a/src/WixToolset.Core/CompilerWarnings.cs
+++ b/src/WixToolset.Core/CompilerWarnings.cs
@@ -60,6 +60,6 @@ namespace WixToolset.Core
60 Win64Component = 5435, 60 Win64Component = 5435,
61 DirectoryRefStandardDirectoryDeprecated = 5436, 61 DirectoryRefStandardDirectoryDeprecated = 5436,
62 DefiningStandardDirectoryDeprecated = 5437, 62 DefiningStandardDirectoryDeprecated = 5437,
63 } 63 } // 5400-5499 and 6600-6699 were the ranges for Dependency and Tag which are now in Core between CompilerWarnings and CompilerErrors.
64 } 64 }
65} 65}
diff --git a/src/WixToolset.Core/Compiler_Bundle.cs b/src/WixToolset.Core/Compiler_Bundle.cs
index 779ad376..e09246df 100644
--- a/src/WixToolset.Core/Compiler_Bundle.cs
+++ b/src/WixToolset.Core/Compiler_Bundle.cs
@@ -2375,6 +2375,7 @@ namespace WixToolset.Core
2375 } 2375 }
2376 2376
2377 this.CreateChainPackageMetaRows(sourceLineNumbers, parentType, parentId, ComplexReferenceChildType.Package, id.Id, previousType, previousId, after); 2377 this.CreateChainPackageMetaRows(sourceLineNumbers, parentType, parentId, ComplexReferenceChildType.Package, id.Id, previousType, previousId, after);
2378 this.Core.CreateGroupAndOrderingRows(sourceLineNumbers, parentType, parentId, ComplexReferenceChildType.ContainerPackage, id.Id, ComplexReferenceChildType.Unknown, null);
2378 } 2379 }
2379 2380
2380 return id.Id; 2381 return id.Id;
diff --git a/src/WixToolset.Core/Link/FlattenAndProcessBundleTablesCommand.cs b/src/WixToolset.Core/Link/FlattenAndProcessBundleTablesCommand.cs
index 0fa48d8c..e8df25ed 100644
--- a/src/WixToolset.Core/Link/FlattenAndProcessBundleTablesCommand.cs
+++ b/src/WixToolset.Core/Link/FlattenAndProcessBundleTablesCommand.cs
@@ -42,46 +42,143 @@ namespace WixToolset.Core.Link
42 // We need to flatten the nested PayloadGroups and PackageGroups under 42 // We need to flatten the nested PayloadGroups and PackageGroups under
43 // UX, Chain, and any Containers. When we're done, the WixGroups table 43 // UX, Chain, and any Containers. When we're done, the WixGroups table
44 // will hold Payloads under UX, ChainPackages (references?) under Chain, 44 // will hold Payloads under UX, ChainPackages (references?) under Chain,
45 // and ChainPackages/Payloads under the attached and any detatched 45 // and ContainerPackages/Payloads under any authored Containers.
46 // Containers.
47 var groups = new WixGroupingOrdering(this.EntrySection, this.Messaging); 46 var groups = new WixGroupingOrdering(this.EntrySection, this.Messaging);
48 47
49 // Create UX payloads and Package payloads 48 // Create UX payloads and Package payloads and Container packages
50 groups.UseTypes(new[] { ComplexReferenceParentType.Container, ComplexReferenceParentType.Layout, ComplexReferenceParentType.PackageGroup, ComplexReferenceParentType.PayloadGroup, ComplexReferenceParentType.Package }, 49 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 }); 50 new[] { ComplexReferenceChildType.ContainerPackage, ComplexReferenceChildType.PackageGroup, ComplexReferenceChildType.Package, ComplexReferenceChildType.PackagePayload, ComplexReferenceChildType.PayloadGroup, ComplexReferenceChildType.Payload });
52 groups.FlattenAndRewriteGroups(ComplexReferenceParentType.Package, false); 51 groups.FlattenAndRewriteGroups(ComplexReferenceParentType.Package, false);
53 groups.FlattenAndRewriteGroups(ComplexReferenceParentType.Container, false); 52 groups.FlattenAndRewriteGroups(ComplexReferenceParentType.Container, false);
54 groups.FlattenAndRewriteGroups(ComplexReferenceParentType.Layout, false); 53 groups.FlattenAndRewriteGroups(ComplexReferenceParentType.Layout, false);
55 54
56 // Create Chain packages... 55 // Create Chain packages...
57 groups.UseTypes(new[] { ComplexReferenceParentType.PackageGroup }, new[] { ComplexReferenceChildType.Package, ComplexReferenceChildType.PackageGroup }); 56 groups.UseTypes(new[] { ComplexReferenceParentType.PackageGroup }, new[] { ComplexReferenceChildType.Package, ComplexReferenceChildType.PackageGroup });
58 groups.FlattenAndRewriteRows(ComplexReferenceChildType.PackageGroup, "WixChain", false); 57 groups.FlattenAndRewriteRows(ComplexReferenceParentType.PackageGroup, "WixChain", false);
59 58
60 groups.RemoveUsedGroupRows(); 59 groups.RemoveUsedGroupRows();
61 } 60 }
62 61
63 private void ProcessBundleComplexReferences() 62 private void ProcessBundleComplexReferences()
64 { 63 {
64 var containersById = this.EntrySection.Symbols.OfType<WixBundleContainerSymbol>().ToDictionary(c => c.Id.Id);
65 var groups = this.EntrySection.Symbols.OfType<WixGroupSymbol>().ToList(); 65 var groups = this.EntrySection.Symbols.OfType<WixGroupSymbol>().ToList();
66 var payloadsById = this.EntrySection.Symbols.OfType<WixBundlePayloadSymbol>().ToDictionary(c => c.Id.Id); 66 var payloadsById = this.EntrySection.Symbols.OfType<WixBundlePayloadSymbol>().ToDictionary(c => c.Id.Id);
67 67
68 var containerByPackage = new Dictionary<string, WixBundleContainerSymbol>();
69 var referencedPackages = new HashSet<string>();
70 var payloadsInBA = new HashSet<string>();
71 var payloadsInPackageOrLayout = new HashSet<string>();
72
73 foreach (var groupSymbol in groups)
74 {
75 switch (groupSymbol.ChildType)
76 {
77 case ComplexReferenceChildType.ContainerPackage:
78 switch (groupSymbol.ParentType)
79 {
80 case ComplexReferenceParentType.Container:
81 if (containerByPackage.TryGetValue(groupSymbol.ChildId, out var collisionContainer))
82 {
83 this.Messaging.Write(LinkerErrors.PackageInMultipleContainers(groupSymbol.SourceLineNumbers, groupSymbol.ChildId, groupSymbol.ParentId, collisionContainer.Id.Id));
84 }
85 else
86 {
87 containerByPackage.Add(groupSymbol.ChildId, containersById[groupSymbol.ParentId]);
88 }
89 break;
90 }
91 break;
92 case ComplexReferenceChildType.Package:
93 switch (groupSymbol.ParentType)
94 {
95 case ComplexReferenceParentType.PackageGroup:
96 if (groupSymbol.ParentId == "WixChain")
97 {
98 referencedPackages.Add(groupSymbol.ChildId);
99 }
100 break;
101 }
102 break;
103 case ComplexReferenceChildType.Payload:
104 switch (groupSymbol.ParentType)
105 {
106 case ComplexReferenceParentType.Container:
107 if (groupSymbol.ParentId == BurnConstants.BurnUXContainerName)
108 {
109 payloadsInBA.Add(groupSymbol.ChildId);
110 }
111 break;
112 case ComplexReferenceParentType.Layout:
113 payloadsById[groupSymbol.ChildId].LayoutOnly = true;
114 payloadsInPackageOrLayout.Add(groupSymbol.ChildId);
115 break;
116 case ComplexReferenceParentType.Package:
117 payloadsInPackageOrLayout.Add(groupSymbol.ChildId);
118 break;
119 }
120 break;
121 }
122 }
123
124 foreach (var package in this.EntrySection.Symbols.OfType<WixBundlePackageSymbol>())
125 {
126 if (!referencedPackages.Contains(package.Id.Id))
127 {
128 this.Messaging.Write(LinkerErrors.UnscheduledChainPackage(package.SourceLineNumbers, package.Id.Id));
129 }
130 }
131
132 foreach (var rollbackBoundary in this.EntrySection.Symbols.OfType<WixBundleRollbackBoundarySymbol>())
133 {
134 if (!referencedPackages.Contains(rollbackBoundary.Id.Id))
135 {
136 this.Messaging.Write(LinkerErrors.UnscheduledRollbackBoundary(rollbackBoundary.SourceLineNumbers, rollbackBoundary.Id.Id));
137 }
138 }
139
140 foreach (var payload in payloadsById.Values)
141 {
142 var payloadId = payload.Id.Id;
143 if (payloadsInBA.Contains(payloadId))
144 {
145 if (payloadsInPackageOrLayout.Contains(payloadId))
146 {
147 this.Messaging.Write(LinkerErrors.PayloadSharedWithBA(payload.SourceLineNumbers, payloadId));
148 }
149 }
150 else if (!payloadsInPackageOrLayout.Contains(payloadId))
151 {
152 this.Messaging.Write(LinkerErrors.OrphanedPayload(payload.SourceLineNumbers, payloadId));
153 }
154 }
155
156 if (this.Messaging.EncounteredError)
157 {
158 return;
159 }
160
68 // Assign authored payloads to authored containers. 161 // 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. 162 // Compressed Payloads not assigned to a container here will get assigned to the default attached container during binding.
70 foreach (var groupSymbol in groups) 163 foreach (var groupSymbol in groups)
71 { 164 {
72 if (ComplexReferenceChildType.Payload == groupSymbol.ChildType) 165 if (groupSymbol.ChildType == ComplexReferenceChildType.Payload && groupSymbol.ParentType == ComplexReferenceParentType.Container)
73 { 166 {
74 var payloadSymbol = payloadsById[groupSymbol.ChildId]; 167 var payloadSymbol = payloadsById[groupSymbol.ChildId];
168 var containerId = groupSymbol.ParentId;
75 169
76 if (ComplexReferenceParentType.Container == groupSymbol.ParentType) 170 if (String.IsNullOrEmpty(payloadSymbol.ContainerRef))
171 {
172 payloadSymbol.ContainerRef = containerId;
173 }
174 else
77 { 175 {
78 // TODO: v3 didn't warn if we overwrote the payload's container. 176 this.Messaging.Write(LinkerWarnings.PayloadInMultipleContainers(groupSymbol.SourceLineNumbers, groupSymbol.ChildId, containerId, payloadSymbol.ContainerRef));
79 // Should we warn now?
80 payloadSymbol.ContainerRef = groupSymbol.ParentId;
81 } 177 }
82 else if (ComplexReferenceParentType.Layout == groupSymbol.ParentType) 178
179 if (payloadSymbol.LayoutOnly)
83 { 180 {
84 payloadSymbol.LayoutOnly = true; 181 this.Messaging.Write(LinkerWarnings.LayoutPayloadInContainer(groupSymbol.SourceLineNumbers, groupSymbol.ChildId, containerId));
85 } 182 }
86 } 183 }
87 } 184 }
diff --git a/src/WixToolset.Core/Link/WixGroupingOrdering.cs b/src/WixToolset.Core/Link/WixGroupingOrdering.cs
index 99220900..f9de82a9 100644
--- a/src/WixToolset.Core/Link/WixGroupingOrdering.cs
+++ b/src/WixToolset.Core/Link/WixGroupingOrdering.cs
@@ -62,7 +62,7 @@ namespace WixToolset.Core.Link
62 /// <param name="parentType">The group type for the parent group to flatten.</param> 62 /// <param name="parentType">The group type for the parent group to flatten.</param>
63 /// <param name="parentId">The identifier of the parent group to flatten.</param> 63 /// <param name="parentId">The identifier of the parent group to flatten.</param>
64 /// <param name="removeUsedRows">Whether to remove used group rows before returning.</param> 64 /// <param name="removeUsedRows">Whether to remove used group rows before returning.</param>
65 public void FlattenAndRewriteRows(ComplexReferenceChildType parentType, string parentId, bool removeUsedRows) 65 public void FlattenAndRewriteRows(ComplexReferenceParentType parentType, string parentId, bool removeUsedRows)
66 { 66 {
67 var parentTypeString = parentType.ToString(); 67 var parentTypeString = parentType.ToString();
68 Debug.Assert(this.groupTypes.Contains(parentTypeString)); 68 Debug.Assert(this.groupTypes.Contains(parentTypeString));
@@ -648,14 +648,11 @@ namespace WixToolset.Core.Link
648 // We *don't* propagate ordering information from Packages or 648 // We *don't* propagate ordering information from Packages or
649 // Containers to their children, because ordering doesn't matter 649 // Containers to their children, because ordering doesn't matter
650 // for them, and a Payload in two Packages (or Containers) can 650 // for them, and a Payload in two Packages (or Containers) can
651 // cause a circular reference to occur. We do, however, need to 651 // cause a circular reference to occur.
652 // track the ordering in the UX Container, because we need the
653 // first payload to be the entrypoint.
654 private bool ShouldItemPropagateChildOrdering() 652 private bool ShouldItemPropagateChildOrdering()
655 { 653 {
656 if (String.Equals(nameof(ComplexReferenceChildType.Package), this.Type, StringComparison.Ordinal) || 654 if (String.Equals(nameof(ComplexReferenceParentType.Package), this.Type, StringComparison.Ordinal) ||
657 (String.Equals(nameof(ComplexReferenceParentType.Container), this.Type, StringComparison.Ordinal) && 655 String.Equals(nameof(ComplexReferenceParentType.Container), this.Type, StringComparison.Ordinal))
658 !String.Equals(BurnConstants.BurnUXContainerName, this.Id, StringComparison.Ordinal)))
659 { 656 {
660 return false; 657 return false;
661 } 658 }
diff --git a/src/WixToolset.Core/LinkerErrors.cs b/src/WixToolset.Core/LinkerErrors.cs
new file mode 100644
index 00000000..7ce8c00e
--- /dev/null
+++ b/src/WixToolset.Core/LinkerErrors.cs
@@ -0,0 +1,48 @@
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
3namespace WixToolset.Core
4{
5 using WixToolset.Data;
6
7 internal static class LinkerErrors
8 {
9 public static Message OrphanedPayload(SourceLineNumber sourceLineNumbers, string payloadId)
10 {
11 return Message(sourceLineNumbers, Ids.OrphanedPayload, "Found orphaned Payload '{0}'. Make sure to reference it from a Package, the BootstrapperApplication, or the Bundle or move it into its own Fragment so it only gets linked in when actually used.", payloadId);
12 }
13
14 public static Message PackageInMultipleContainers(SourceLineNumber sourceLineNumbers, string packageId, string containerId1, string containerId2)
15 {
16 return Message(sourceLineNumbers, Ids.PackageInMultipleContainers, "The Package '{0}' is referenced from multiple containers - Container '{1}' and Container '{2}'. This is not currently supported.", packageId, containerId1, containerId2);
17 }
18
19 public static Message PayloadSharedWithBA(SourceLineNumber sourceLineNumbers, string payloadId)
20 {
21 return Message(sourceLineNumbers, Ids.PayloadSharedWithBA, "The Payload '{0}' is shared with the BootstrapperApplication. This is not currently supported.", payloadId);
22 }
23
24 public static Message UnscheduledChainPackage(SourceLineNumber sourceLineNumbers, string packageId)
25 {
26 return Message(sourceLineNumbers, Ids.UnscheduledChainPackage, "Found orphaned Package '{0}'. Make sure to reference it from the Chain or move it into its own Fragment so it only gets linked in when actually used.", packageId);
27 }
28
29 public static Message UnscheduledRollbackBoundary(SourceLineNumber sourceLineNumbers, string rollbackBoundaryId)
30 {
31 return Message(sourceLineNumbers, Ids.UnscheduledRollbackBoundary, "Found orphaned RollbackBoundary '{0}'. Make sure to reference it from the Chain or move it into its own Fragment so it only gets linked in when actually used.", rollbackBoundaryId);
32 }
33
34 private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args)
35 {
36 return new Message(sourceLineNumber, MessageLevel.Error, (int)id, format, args);
37 }
38
39 public enum Ids
40 {
41 OrphanedPayload = 7000,
42 PackageInMultipleContainers = 7001,
43 PayloadSharedWithBA = 7002,
44 UnscheduledChainPackage = 7003,
45 UnscheduledRollbackBoundary = 7004,
46 } // last available is 7099. 7100 is WindowsInstallerBackendWarnings.
47 }
48}
diff --git a/src/WixToolset.Core/LinkerWarnings.cs b/src/WixToolset.Core/LinkerWarnings.cs
new file mode 100644
index 00000000..0eca090e
--- /dev/null
+++ b/src/WixToolset.Core/LinkerWarnings.cs
@@ -0,0 +1,30 @@
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
3namespace WixToolset.Core
4{
5 using WixToolset.Data;
6
7 internal static class LinkerWarnings
8 {
9 public static Message LayoutPayloadInContainer(SourceLineNumber sourceLineNumbers, string payloadId, string containerId)
10 {
11 return Message(sourceLineNumbers, Ids.LayoutPayloadInContainer, "The layout-only Payload '{0}' is being added to Container '{1}'. It will not be extracted during layout.", payloadId, containerId);
12 }
13
14 public static Message PayloadInMultipleContainers(SourceLineNumber sourceLineNumbers, string payloadId, string containerId1, string containerId2)
15 {
16 return Message(sourceLineNumbers, Ids.PayloadInMultipleContainers, "The Payload '{0}' can't be added to Container '{1}' because it was already added to Container '{2}'.", payloadId, containerId1, containerId2);
17 }
18
19 private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args)
20 {
21 return new Message(sourceLineNumber, MessageLevel.Warning, (int)id, format, args);
22 }
23
24 public enum Ids
25 {
26 LayoutPayloadInContainer = 6900,
27 PayloadInMultipleContainers = 6901,
28 } // last available is 6999. 7000 is LinkerErrors.
29 }
30}
diff --git a/src/WixToolset.Core/WixToolset.Core.csproj b/src/WixToolset.Core/WixToolset.Core.csproj
index 902f63ce..7242d500 100644
--- a/src/WixToolset.Core/WixToolset.Core.csproj
+++ b/src/WixToolset.Core/WixToolset.Core.csproj
@@ -14,6 +14,18 @@
14 </PropertyGroup> 14 </PropertyGroup>
15 15
16 <ItemGroup> 16 <ItemGroup>
17 <AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
18 <_Parameter1>WixToolset.Core.TestPackage, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a9967ec28982f42ee51a47dd5204315975a6ed69294b982146a99a70130a2fa13e226aaddde14c17d1bf3af69e8956d69a86585e74d208efcc5ac98a0686055327b2e87960d3c39bf3a6bc1e572863327d19dbf4fd2616dda124dbea260755a2d1d39d3cf1049ea526493eb2bf996b8ad985e3012308529e5b9b0f5cd5fa04bd</_Parameter1>
19 </AssemblyAttribute>
20 <AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
21 <_Parameter1>WixToolsetTest.Core.Burn, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a9967ec28982f42ee51a47dd5204315975a6ed69294b982146a99a70130a2fa13e226aaddde14c17d1bf3af69e8956d69a86585e74d208efcc5ac98a0686055327b2e87960d3c39bf3a6bc1e572863327d19dbf4fd2616dda124dbea260755a2d1d39d3cf1049ea526493eb2bf996b8ad985e3012308529e5b9b0f5cd5fa04bd</_Parameter1>
22 </AssemblyAttribute>
23 <AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
24 <_Parameter1>WixToolsetTest.CoreIntegration, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a9967ec28982f42ee51a47dd5204315975a6ed69294b982146a99a70130a2fa13e226aaddde14c17d1bf3af69e8956d69a86585e74d208efcc5ac98a0686055327b2e87960d3c39bf3a6bc1e572863327d19dbf4fd2616dda124dbea260755a2d1d39d3cf1049ea526493eb2bf996b8ad985e3012308529e5b9b0f5cd5fa04bd</_Parameter1>
25 </AssemblyAttribute>
26 </ItemGroup>
27
28 <ItemGroup>
17 <PackageReference Include="WixToolset.Data" Version="4.0.*" /> 29 <PackageReference Include="WixToolset.Data" Version="4.0.*" />
18 <PackageReference Include="WixToolset.Extensibility" Version="4.0.*" /> 30 <PackageReference Include="WixToolset.Extensibility" Version="4.0.*" />
19 <PackageReference Include="WixToolset.Core.Native" Version="4.0.*" /> 31 <PackageReference Include="WixToolset.Core.Native" Version="4.0.*" />