diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2021-04-24 16:28:44 -0500 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2021-04-25 23:06:35 -0500 |
commit | f4709371fa21ca1d0c06e04d1b53c0b10bfafeed (patch) | |
tree | 622576e0b46b0cea56143fd707936f9635389bad | |
parent | 23de0a19bffe457916b0a45e07044650ace8f456 (diff) | |
download | wix-f4709371fa21ca1d0c06e04d1b53c0b10bfafeed.tar.gz wix-f4709371fa21ca1d0c06e04d1b53c0b10bfafeed.tar.bz2 wix-f4709371fa21ca1d0c06e04d1b53c0b10bfafeed.zip |
Perform more bundle validation during linking.
#5273, #6291, #6398
24 files changed, 492 insertions, 115 deletions
diff --git a/src/WixToolset.Core.Burn/BurnBackendErrors.cs b/src/WixToolset.Core.Burn/BurnBackendErrors.cs index f23db47d..854c84e0 100644 --- a/src/WixToolset.Core.Burn/BurnBackendErrors.cs +++ b/src/WixToolset.Core.Burn/BurnBackendErrors.cs | |||
@@ -67,6 +67,6 @@ namespace WixToolset.Core.Burn | |||
67 | PackageCachePayloadCollision = 8006, | 67 | PackageCachePayloadCollision = 8006, |
68 | PackageCachePayloadCollision2 = 8007, | 68 | PackageCachePayloadCollision2 = 8007, |
69 | MultipleAttachedContainersUnsupported = 8008, | 69 | MultipleAttachedContainersUnsupported = 8008, |
70 | } | 70 | } // last available is 8499. 8500 is BurnBackendWarnings. |
71 | } | 71 | } |
72 | } | 72 | } |
diff --git a/src/WixToolset.Core.Burn/BurnBackendWarnings.cs b/src/WixToolset.Core.Burn/BurnBackendWarnings.cs index 5edbbd67..a0ffa1dc 100644 --- a/src/WixToolset.Core.Burn/BurnBackendWarnings.cs +++ b/src/WixToolset.Core.Burn/BurnBackendWarnings.cs | |||
@@ -31,6 +31,6 @@ namespace WixToolset.Core.Burn | |||
31 | AttachedContainerPayloadCollision = 8500, | 31 | AttachedContainerPayloadCollision = 8500, |
32 | AttachedContainerPayloadCollision2 = 8501, | 32 | AttachedContainerPayloadCollision2 = 8501, |
33 | EmptyContainer = 8502, | 33 | EmptyContainer = 8502, |
34 | } | 34 | } // last available is 8999. 9000 is VerboseMessages. |
35 | } | 35 | } |
36 | } | 36 | } |
diff --git a/src/WixToolset.Core.WindowsInstaller/WindowsInstallerBackendErrors.cs b/src/WixToolset.Core.WindowsInstaller/WindowsInstallerBackendErrors.cs index c1232dcc..0c15ad05 100644 --- a/src/WixToolset.Core.WindowsInstaller/WindowsInstallerBackendErrors.cs +++ b/src/WixToolset.Core.WindowsInstaller/WindowsInstallerBackendErrors.cs | |||
@@ -18,7 +18,7 @@ namespace WixToolset.Core.WindowsInstaller | |||
18 | 18 | ||
19 | public enum Ids | 19 | public enum Ids |
20 | { | 20 | { |
21 | // ReplaceThisWithTheFirstError = 7000, | 21 | // ReplaceThisWithTheFirstError = 7500, |
22 | } | 22 | } // last available is 7999. 8000 is BurnBackendErrors. |
23 | } | 23 | } |
24 | } | 24 | } |
diff --git a/src/WixToolset.Core.WindowsInstaller/WindowsInstallerBackendWarnings.cs b/src/WixToolset.Core.WindowsInstaller/WindowsInstallerBackendWarnings.cs index 0eaadbe1..d0986a4d 100644 --- a/src/WixToolset.Core.WindowsInstaller/WindowsInstallerBackendWarnings.cs +++ b/src/WixToolset.Core.WindowsInstaller/WindowsInstallerBackendWarnings.cs | |||
@@ -18,7 +18,7 @@ namespace WixToolset.Core.WindowsInstaller | |||
18 | 18 | ||
19 | public enum Ids | 19 | public enum Ids |
20 | { | 20 | { |
21 | // ReplaceThisWithTheFirstWarning = 7500, | 21 | // ReplaceThisWithTheFirstWarning = 7100, |
22 | } | 22 | } // last available is 7499. 7500 is WindowsInstallerBackendErrors. |
23 | } | 23 | } |
24 | } | 24 | } |
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 | |||
3 | namespace 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 | |||
3 | namespace 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.*" /> |
diff --git a/src/test/WixToolsetTest.CoreIntegration/BundleFixture.cs b/src/test/WixToolsetTest.CoreIntegration/BundleFixture.cs index cc91d212..ab644080 100644 --- a/src/test/WixToolsetTest.CoreIntegration/BundleFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/BundleFixture.cs | |||
@@ -10,6 +10,7 @@ namespace WixToolsetTest.CoreIntegration | |||
10 | using System.Xml; | 10 | using System.Xml; |
11 | using Example.Extension; | 11 | using Example.Extension; |
12 | using WixBuildTools.TestSupport; | 12 | using WixBuildTools.TestSupport; |
13 | using WixToolset.Core; | ||
13 | using WixToolset.Core.Burn; | 14 | using WixToolset.Core.Burn; |
14 | using WixToolset.Core.TestPackage; | 15 | using WixToolset.Core.TestPackage; |
15 | using WixToolset.Data; | 16 | using WixToolset.Data; |
@@ -368,7 +369,61 @@ namespace WixToolsetTest.CoreIntegration | |||
368 | } | 369 | } |
369 | } | 370 | } |
370 | 371 | ||
371 | [Fact(Skip = "https://github.com/wixtoolset/issues/issues/6291")] | 372 | [Fact] |
373 | public void CantBuildWithOrphanPayload() | ||
374 | { | ||
375 | var folder = TestData.Get(@"TestData"); | ||
376 | |||
377 | using (var fs = new DisposableFileSystem()) | ||
378 | { | ||
379 | var baseFolder = fs.GetFolder(); | ||
380 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
381 | var exePath = Path.Combine(baseFolder, @"bin\test.exe"); | ||
382 | |||
383 | var result = WixRunner.Execute(new[] | ||
384 | { | ||
385 | "build", | ||
386 | Path.Combine(folder, "BadInput", "OrphanPayload.wxs"), | ||
387 | Path.Combine(folder, "BundleWithPackageGroupRef", "Bundle.wxs"), | ||
388 | Path.Combine(folder, "BundleWithPackageGroupRef", "MinimalPackageGroup.wxs"), | ||
389 | "-bindpath", Path.Combine(folder, "SimpleBundle", "data"), | ||
390 | "-bindpath", Path.Combine(folder, ".Data"), | ||
391 | "-intermediateFolder", intermediateFolder, | ||
392 | "-o", exePath, | ||
393 | }); | ||
394 | |||
395 | Assert.Equal((int)LinkerErrors.Ids.OrphanedPayload, result.ExitCode); | ||
396 | } | ||
397 | } | ||
398 | |||
399 | [Fact] | ||
400 | public void CantBuildWithPackageInMultipleContainers() | ||
401 | { | ||
402 | var folder = TestData.Get(@"TestData"); | ||
403 | |||
404 | using (var fs = new DisposableFileSystem()) | ||
405 | { | ||
406 | var baseFolder = fs.GetFolder(); | ||
407 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
408 | var exePath = Path.Combine(baseFolder, @"bin\test.exe"); | ||
409 | |||
410 | var result = WixRunner.Execute(new[] | ||
411 | { | ||
412 | "build", | ||
413 | Path.Combine(folder, "BadInput", "PackageInMultipleContainers.wxs"), | ||
414 | Path.Combine(folder, "BundleWithPackageGroupRef", "Bundle.wxs"), | ||
415 | Path.Combine(folder, "BundleWithPackageGroupRef", "MinimalPackageGroup.wxs"), | ||
416 | "-bindpath", Path.Combine(folder, "SimpleBundle", "data"), | ||
417 | "-bindpath", Path.Combine(folder, ".Data"), | ||
418 | "-intermediateFolder", intermediateFolder, | ||
419 | "-o", exePath, | ||
420 | }); | ||
421 | |||
422 | Assert.Equal((int)LinkerErrors.Ids.PackageInMultipleContainers, result.ExitCode); | ||
423 | } | ||
424 | } | ||
425 | |||
426 | [Fact] | ||
372 | public void CantBuildWithUnscheduledPackage() | 427 | public void CantBuildWithUnscheduledPackage() |
373 | { | 428 | { |
374 | var folder = TestData.Get(@"TestData"); | 429 | var folder = TestData.Get(@"TestData"); |
@@ -390,11 +445,11 @@ namespace WixToolsetTest.CoreIntegration | |||
390 | "-o", exePath, | 445 | "-o", exePath, |
391 | }); | 446 | }); |
392 | 447 | ||
393 | Assert.InRange(result.ExitCode, 2, Int32.MaxValue); | 448 | Assert.Equal((int)LinkerErrors.Ids.UnscheduledChainPackage, result.ExitCode); |
394 | } | 449 | } |
395 | } | 450 | } |
396 | 451 | ||
397 | [Fact(Skip = "https://github.com/wixtoolset/issues/issues/6291")] | 452 | [Fact] |
398 | public void CantBuildWithUnscheduledRollbackBoundary() | 453 | public void CantBuildWithUnscheduledRollbackBoundary() |
399 | { | 454 | { |
400 | var folder = TestData.Get(@"TestData"); | 455 | var folder = TestData.Get(@"TestData"); |
@@ -416,7 +471,7 @@ namespace WixToolsetTest.CoreIntegration | |||
416 | "-o", exePath, | 471 | "-o", exePath, |
417 | }); | 472 | }); |
418 | 473 | ||
419 | Assert.InRange(result.ExitCode, 2, Int32.MaxValue); | 474 | Assert.Equal((int)LinkerErrors.Ids.UnscheduledRollbackBoundary, result.ExitCode); |
420 | } | 475 | } |
421 | } | 476 | } |
422 | } | 477 | } |
diff --git a/src/test/WixToolsetTest.CoreIntegration/BundleManifestFixture.cs b/src/test/WixToolsetTest.CoreIntegration/BundleManifestFixture.cs index 4a8473df..29c741dc 100644 --- a/src/test/WixToolsetTest.CoreIntegration/BundleManifestFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/BundleManifestFixture.cs | |||
@@ -291,7 +291,7 @@ namespace WixToolsetTest.CoreIntegration | |||
291 | var baFolderPath = Path.Combine(baseFolder, "ba"); | 291 | var baFolderPath = Path.Combine(baseFolder, "ba"); |
292 | var extractFolderPath = Path.Combine(baseFolder, "extract"); | 292 | var extractFolderPath = Path.Combine(baseFolder, "extract"); |
293 | 293 | ||
294 | var result = WixRunner.Execute(false, new[] | 294 | var result = WixRunner.Execute(new[] |
295 | { | 295 | { |
296 | "build", | 296 | "build", |
297 | Path.Combine(folder, "SharedPayloadsBetweenPackages", "SharedPayloadsBetweenPackages.wxs"), | 297 | Path.Combine(folder, "SharedPayloadsBetweenPackages", "SharedPayloadsBetweenPackages.wxs"), |
@@ -315,8 +315,8 @@ namespace WixToolsetTest.CoreIntegration | |||
315 | { "ExePackage", new List<string> { "CacheId", "InstallSize", "Size" } }, | 315 | { "ExePackage", new List<string> { "CacheId", "InstallSize", "Size" } }, |
316 | }; | 316 | }; |
317 | Assert.Equal(2, exePackageElements.Count); | 317 | Assert.Equal(2, exePackageElements.Count); |
318 | Assert.Equal("<ExePackage Id='credwiz.exe' Cache='keep' CacheId='*' InstallSize='*' Size='*' PerMachine='yes' Permanent='yes' Vital='yes' RollbackBoundaryForward='WixDefaultBoundary' LogPathVariable='WixBundleLog_credwiz.exe' RollbackLogPathVariable='WixBundleRollbackLog_credwiz.exe' DetectCondition='' InstallArguments='' UninstallArguments='' RepairArguments='' Repairable='no'><PayloadRef Id='credwiz.exe' /><PayloadRef Id='SourceFilePayload' /></ExePackage>", exePackageElements[0].GetTestXml(ignoreAttributesByElementName)); | 318 | Assert.Equal("<ExePackage Id='credwiz.exe' Cache='keep' CacheId='*' InstallSize='*' Size='*' PerMachine='yes' Permanent='yes' Vital='yes' RollbackBoundaryForward='WixDefaultBoundary' LogPathVariable='WixBundleLog_credwiz.exe' RollbackLogPathVariable='WixBundleRollbackLog_credwiz.exe' DetectCondition='none' InstallArguments='' UninstallArguments='' RepairArguments='' Repairable='no'><PayloadRef Id='credwiz.exe' /><PayloadRef Id='SourceFilePayload' /></ExePackage>", exePackageElements[0].GetTestXml(ignoreAttributesByElementName)); |
319 | Assert.Equal("<ExePackage Id='cscript.exe' Cache='keep' CacheId='*' InstallSize='*' Size='*' PerMachine='yes' Permanent='yes' Vital='yes' RollbackBoundaryBackward='WixDefaultBoundary' LogPathVariable='WixBundleLog_cscript.exe' RollbackLogPathVariable='WixBundleRollbackLog_cscript.exe' DetectCondition='' InstallArguments='' UninstallArguments='' RepairArguments='' Repairable='no'><PayloadRef Id='cscript.exe' /><PayloadRef Id='SourceFilePayload' /></ExePackage>", exePackageElements[1].GetTestXml(ignoreAttributesByElementName)); | 319 | Assert.Equal("<ExePackage Id='cscript.exe' Cache='keep' CacheId='*' InstallSize='*' Size='*' PerMachine='yes' Permanent='yes' Vital='yes' RollbackBoundaryBackward='WixDefaultBoundary' LogPathVariable='WixBundleLog_cscript.exe' RollbackLogPathVariable='WixBundleRollbackLog_cscript.exe' DetectCondition='none' InstallArguments='' UninstallArguments='' RepairArguments='' Repairable='no'><PayloadRef Id='cscript.exe' /><PayloadRef Id='SourceFilePayload' /></ExePackage>", exePackageElements[1].GetTestXml(ignoreAttributesByElementName)); |
320 | } | 320 | } |
321 | } | 321 | } |
322 | 322 | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/ContainerFixture.cs b/src/test/WixToolsetTest.CoreIntegration/ContainerFixture.cs index f24429f7..ffeda069 100644 --- a/src/test/WixToolsetTest.CoreIntegration/ContainerFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/ContainerFixture.cs | |||
@@ -8,10 +8,9 @@ namespace WixToolsetTest.CoreIntegration | |||
8 | using System.Linq; | 8 | using System.Linq; |
9 | using System.Xml; | 9 | using System.Xml; |
10 | using WixBuildTools.TestSupport; | 10 | using WixBuildTools.TestSupport; |
11 | using WixToolset.Core; | ||
11 | using WixToolset.Core.Burn; | 12 | using WixToolset.Core.Burn; |
12 | using WixToolset.Core.TestPackage; | 13 | using WixToolset.Core.TestPackage; |
13 | using WixToolset.Data; | ||
14 | using WixToolset.Data.Symbols; | ||
15 | using Xunit; | 14 | using Xunit; |
16 | 15 | ||
17 | public class ContainerFixture | 16 | public class ContainerFixture |
@@ -30,33 +29,9 @@ namespace WixToolsetTest.CoreIntegration | |||
30 | var baFolderPath = Path.Combine(baseFolder, "ba"); | 29 | var baFolderPath = Path.Combine(baseFolder, "ba"); |
31 | var extractFolderPath = Path.Combine(baseFolder, "extract"); | 30 | var extractFolderPath = Path.Combine(baseFolder, "extract"); |
32 | 31 | ||
33 | var result = WixRunner.Execute(new[] | 32 | this.BuildMsis(folder, intermediateFolder, binFolder); |
34 | { | ||
35 | "build", | ||
36 | Path.Combine(folder, "MsiTransaction", "FirstX86.wxs"), | ||
37 | Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"), | ||
38 | Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), | ||
39 | "-bindpath", Path.Combine(folder, "SingleFile", "data"), | ||
40 | "-intermediateFolder", intermediateFolder, | ||
41 | "-o", Path.Combine(binFolder, "FirstX86.msi"), | ||
42 | }); | ||
43 | |||
44 | result.AssertSuccess(); | ||
45 | 33 | ||
46 | result = WixRunner.Execute(new[] | 34 | var result = WixRunner.Execute(new[] |
47 | { | ||
48 | "build", | ||
49 | Path.Combine(folder, "MsiTransaction", "FirstX64.wxs"), | ||
50 | Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"), | ||
51 | Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), | ||
52 | "-bindpath", Path.Combine(folder, "SingleFile", "data"), | ||
53 | "-intermediateFolder", intermediateFolder, | ||
54 | "-o", Path.Combine(binFolder, "FirstX64.msi"), | ||
55 | }); | ||
56 | |||
57 | result.AssertSuccess(); | ||
58 | |||
59 | result = WixRunner.Execute(new[] | ||
60 | { | 35 | { |
61 | "build", | 36 | "build", |
62 | Path.Combine(folder, "Container", "HarvestIntoDetachedContainer.wxs"), | 37 | Path.Combine(folder, "Container", "HarvestIntoDetachedContainer.wxs"), |
@@ -98,33 +73,9 @@ namespace WixToolsetTest.CoreIntegration | |||
98 | var baFolderPath = Path.Combine(baseFolder, "ba"); | 73 | var baFolderPath = Path.Combine(baseFolder, "ba"); |
99 | var extractFolderPath = Path.Combine(baseFolder, "extract"); | 74 | var extractFolderPath = Path.Combine(baseFolder, "extract"); |
100 | 75 | ||
101 | var result = WixRunner.Execute(new[] | 76 | this.BuildMsis(folder, intermediateFolder, binFolder); |
102 | { | ||
103 | "build", | ||
104 | Path.Combine(folder, "MsiTransaction", "FirstX86.wxs"), | ||
105 | Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"), | ||
106 | Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), | ||
107 | "-bindpath", Path.Combine(folder, "SingleFile", "data"), | ||
108 | "-intermediateFolder", intermediateFolder, | ||
109 | "-o", Path.Combine(binFolder, "FirstX86.msi"), | ||
110 | }); | ||
111 | |||
112 | result.AssertSuccess(); | ||
113 | |||
114 | result = WixRunner.Execute(new[] | ||
115 | { | ||
116 | "build", | ||
117 | Path.Combine(folder, "MsiTransaction", "FirstX64.wxs"), | ||
118 | Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"), | ||
119 | Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), | ||
120 | "-bindpath", Path.Combine(folder, "SingleFile", "data"), | ||
121 | "-intermediateFolder", intermediateFolder, | ||
122 | "-o", Path.Combine(binFolder, "FirstX64.msi"), | ||
123 | }); | ||
124 | |||
125 | result.AssertSuccess(); | ||
126 | 77 | ||
127 | result = WixRunner.Execute(new[] | 78 | var result = WixRunner.Execute(new[] |
128 | { | 79 | { |
129 | "build", | 80 | "build", |
130 | Path.Combine(folder, "Container", "HarvestIntoDetachedContainer.wxs"), | 81 | Path.Combine(folder, "Container", "HarvestIntoDetachedContainer.wxs"), |
@@ -174,7 +125,7 @@ namespace WixToolsetTest.CoreIntegration | |||
174 | } | 125 | } |
175 | 126 | ||
176 | [Fact] | 127 | [Fact] |
177 | public void MultipleAttachedContainersAreNotCurrentlySupported() | 128 | public void LayoutPayloadIsPutInContainer() |
178 | { | 129 | { |
179 | var folder = TestData.Get(@"TestData"); | 130 | var folder = TestData.Get(@"TestData"); |
180 | 131 | ||
@@ -187,36 +138,92 @@ namespace WixToolsetTest.CoreIntegration | |||
187 | var baFolderPath = Path.Combine(baseFolder, "ba"); | 138 | var baFolderPath = Path.Combine(baseFolder, "ba"); |
188 | var extractFolderPath = Path.Combine(baseFolder, "extract"); | 139 | var extractFolderPath = Path.Combine(baseFolder, "extract"); |
189 | 140 | ||
190 | var result = WixRunner.Execute(new[] | 141 | this.BuildMsis(folder, intermediateFolder, binFolder); |
142 | |||
143 | var result = WixRunner.Execute(false, new[] | ||
191 | { | 144 | { |
192 | "build", | 145 | "build", |
193 | Path.Combine(folder, "MsiTransaction", "FirstX86.wxs"), | 146 | Path.Combine(folder, "Container", "LayoutPayloadInContainer.wxs"), |
194 | Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"), | 147 | "-bindpath", Path.Combine(folder, "SimpleBundle", "data"), |
195 | Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), | 148 | "-bindpath", binFolder, |
196 | "-bindpath", Path.Combine(folder, "SingleFile", "data"), | ||
197 | "-intermediateFolder", intermediateFolder, | 149 | "-intermediateFolder", intermediateFolder, |
198 | "-o", Path.Combine(binFolder, "FirstX86.msi"), | 150 | "-o", bundlePath |
199 | }); | 151 | }); |
200 | 152 | ||
153 | WixAssert.CompareLineByLine(new string[] | ||
154 | { | ||
155 | "The layout-only Payload 'SharedPayload' is being added to Container 'FirstX64'. It will not be extracted during layout.", | ||
156 | }, result.Messages.Select(m => m.ToString()).ToArray()); | ||
201 | result.AssertSuccess(); | 157 | result.AssertSuccess(); |
202 | 158 | ||
203 | result = WixRunner.Execute(new[] | 159 | Assert.True(File.Exists(bundlePath)); |
160 | |||
161 | var extractResult = BundleExtractor.ExtractBAContainer(null, bundlePath, baFolderPath, extractFolderPath); | ||
162 | extractResult.AssertSuccess(); | ||
163 | |||
164 | var ignoreAttributes = new Dictionary<string, List<string>> { { "Payload", new List<string> { "FileSize", "Hash" } } }; | ||
165 | var payloads = extractResult.SelectManifestNodes("/burn:BurnManifest/burn:Payload[@Id='SharedPayload']") | ||
166 | .Cast<XmlElement>() | ||
167 | .Select(e => e.GetTestXml(ignoreAttributes)) | ||
168 | .ToArray(); | ||
169 | WixAssert.CompareLineByLine(new string[] | ||
170 | { | ||
171 | "<Payload Id='SharedPayload' FilePath='LayoutPayloadInContainer.wxs' FileSize='*' Hash='*' LayoutOnly='yes' Packaging='embedded' SourcePath='a1' Container='FirstX64' />", | ||
172 | }, payloads); | ||
173 | } | ||
174 | } | ||
175 | |||
176 | [Fact] | ||
177 | public void MultipleAttachedContainersAreNotCurrentlySupported() | ||
178 | { | ||
179 | var folder = TestData.Get(@"TestData"); | ||
180 | |||
181 | using (var fs = new DisposableFileSystem()) | ||
182 | { | ||
183 | var baseFolder = fs.GetFolder(); | ||
184 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
185 | var binFolder = Path.Combine(baseFolder, "bin"); | ||
186 | var bundlePath = Path.Combine(binFolder, "test.exe"); | ||
187 | var baFolderPath = Path.Combine(baseFolder, "ba"); | ||
188 | var extractFolderPath = Path.Combine(baseFolder, "extract"); | ||
189 | |||
190 | this.BuildMsis(folder, intermediateFolder, binFolder); | ||
191 | |||
192 | var result = WixRunner.Execute(new[] | ||
204 | { | 193 | { |
205 | "build", | 194 | "build", |
206 | Path.Combine(folder, "MsiTransaction", "FirstX64.wxs"), | 195 | Path.Combine(folder, "Container", "MultipleAttachedContainers.wxs"), |
207 | Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"), | 196 | Path.Combine(folder, "BundleWithPackageGroupRef", "Bundle.wxs"), |
208 | Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), | 197 | "-bindpath", Path.Combine(folder, "SimpleBundle", "data"), |
209 | "-bindpath", Path.Combine(folder, "SingleFile", "data"), | 198 | "-bindpath", binFolder, |
210 | "-intermediateFolder", intermediateFolder, | 199 | "-intermediateFolder", intermediateFolder, |
211 | "-o", Path.Combine(binFolder, "FirstX64.msi"), | 200 | "-o", bundlePath |
212 | }); | 201 | }); |
213 | 202 | ||
214 | result.AssertSuccess(); | 203 | Assert.Equal((int)BurnBackendErrors.Ids.MultipleAttachedContainersUnsupported, result.ExitCode); |
204 | } | ||
205 | } | ||
206 | |||
207 | [Fact] | ||
208 | public void PayloadIsNotPutInMultipleContainers() | ||
209 | { | ||
210 | var folder = TestData.Get(@"TestData"); | ||
211 | |||
212 | using (var fs = new DisposableFileSystem()) | ||
213 | { | ||
214 | var baseFolder = fs.GetFolder(); | ||
215 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
216 | var binFolder = Path.Combine(baseFolder, "bin"); | ||
217 | var bundlePath = Path.Combine(binFolder, "test.exe"); | ||
218 | var baFolderPath = Path.Combine(baseFolder, "ba"); | ||
219 | var extractFolderPath = Path.Combine(baseFolder, "extract"); | ||
220 | |||
221 | this.BuildMsis(folder, intermediateFolder, binFolder); | ||
215 | 222 | ||
216 | result = WixRunner.Execute(new[] | 223 | var result = WixRunner.Execute(false, new[] |
217 | { | 224 | { |
218 | "build", | 225 | "build", |
219 | Path.Combine(folder, "Container", "MultipleAttachedContainers.wxs"), | 226 | Path.Combine(folder, "Container", "PayloadInMultipleContainers.wxs"), |
220 | Path.Combine(folder, "BundleWithPackageGroupRef", "Bundle.wxs"), | 227 | Path.Combine(folder, "BundleWithPackageGroupRef", "Bundle.wxs"), |
221 | "-bindpath", Path.Combine(folder, "SimpleBundle", "data"), | 228 | "-bindpath", Path.Combine(folder, "SimpleBundle", "data"), |
222 | "-bindpath", binFolder, | 229 | "-bindpath", binFolder, |
@@ -224,8 +231,56 @@ namespace WixToolsetTest.CoreIntegration | |||
224 | "-o", bundlePath | 231 | "-o", bundlePath |
225 | }); | 232 | }); |
226 | 233 | ||
227 | Assert.Equal((int)BurnBackendErrors.Ids.MultipleAttachedContainersUnsupported, result.ExitCode); | 234 | WixAssert.CompareLineByLine(new string[] |
235 | { | ||
236 | "The Payload 'SharedPayload' can't be added to Container 'FirstX64' because it was already added to Container 'FirstX86'.", | ||
237 | }, result.Messages.Select(m => m.ToString()).ToArray()); | ||
238 | result.AssertSuccess(); | ||
239 | |||
240 | Assert.True(File.Exists(bundlePath)); | ||
241 | |||
242 | var extractResult = BundleExtractor.ExtractBAContainer(null, bundlePath, baFolderPath, extractFolderPath); | ||
243 | extractResult.AssertSuccess(); | ||
244 | |||
245 | var ignoreAttributes = new Dictionary<string, List<string>> { { "Payload", new List<string> { "FileSize", "Hash" } } }; | ||
246 | var payloads = extractResult.SelectManifestNodes("/burn:BurnManifest/burn:Payload[@Id='SharedPayload']") | ||
247 | .Cast<XmlElement>() | ||
248 | .Select(e => e.GetTestXml(ignoreAttributes)) | ||
249 | .ToArray(); | ||
250 | WixAssert.CompareLineByLine(new string[] | ||
251 | { | ||
252 | "<Payload Id='SharedPayload' FilePath='PayloadInMultipleContainers.wxs' FileSize='*' Hash='*' Packaging='embedded' SourcePath='a2' Container='FirstX86' />", | ||
253 | }, payloads); | ||
228 | } | 254 | } |
229 | } | 255 | } |
256 | |||
257 | private void BuildMsis(string folder, string intermediateFolder, string binFolder) | ||
258 | { | ||
259 | var result = WixRunner.Execute(new[] | ||
260 | { | ||
261 | "build", | ||
262 | Path.Combine(folder, "MsiTransaction", "FirstX86.wxs"), | ||
263 | Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"), | ||
264 | Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), | ||
265 | "-bindpath", Path.Combine(folder, "SingleFile", "data"), | ||
266 | "-intermediateFolder", intermediateFolder, | ||
267 | "-o", Path.Combine(binFolder, "FirstX86.msi"), | ||
268 | }); | ||
269 | |||
270 | result.AssertSuccess(); | ||
271 | |||
272 | result = WixRunner.Execute(new[] | ||
273 | { | ||
274 | "build", | ||
275 | Path.Combine(folder, "MsiTransaction", "FirstX64.wxs"), | ||
276 | Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"), | ||
277 | Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), | ||
278 | "-bindpath", Path.Combine(folder, "SingleFile", "data"), | ||
279 | "-intermediateFolder", intermediateFolder, | ||
280 | "-o", Path.Combine(binFolder, "FirstX64.msi"), | ||
281 | }); | ||
282 | |||
283 | result.AssertSuccess(); | ||
284 | } | ||
230 | } | 285 | } |
231 | } | 286 | } |
diff --git a/src/test/WixToolsetTest.CoreIntegration/PayloadFixture.cs b/src/test/WixToolsetTest.CoreIntegration/PayloadFixture.cs index e9e59b9e..da87bf6c 100644 --- a/src/test/WixToolsetTest.CoreIntegration/PayloadFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/PayloadFixture.cs | |||
@@ -8,6 +8,7 @@ namespace WixToolsetTest.CoreIntegration | |||
8 | using System.Linq; | 8 | using System.Linq; |
9 | using System.Xml; | 9 | using System.Xml; |
10 | using WixBuildTools.TestSupport; | 10 | using WixBuildTools.TestSupport; |
11 | using WixToolset.Core; | ||
11 | using WixToolset.Core.TestPackage; | 12 | using WixToolset.Core.TestPackage; |
12 | using WixToolset.Data; | 13 | using WixToolset.Data; |
13 | using WixToolset.Data.Symbols; | 14 | using WixToolset.Data.Symbols; |
@@ -117,7 +118,7 @@ namespace WixToolsetTest.CoreIntegration | |||
117 | } | 118 | } |
118 | } | 119 | } |
119 | 120 | ||
120 | [Fact(Skip = "https://github.com/wixtoolset/issues/issues/5273")] | 121 | [Fact] |
121 | public void RejectsPayloadSharedBetweenPackageAndBA() | 122 | public void RejectsPayloadSharedBetweenPackageAndBA() |
122 | { | 123 | { |
123 | var folder = TestData.Get(@"TestData"); | 124 | var folder = TestData.Get(@"TestData"); |
@@ -139,7 +140,7 @@ namespace WixToolsetTest.CoreIntegration | |||
139 | "-o", bundlePath, | 140 | "-o", bundlePath, |
140 | }); | 141 | }); |
141 | 142 | ||
142 | Assert.InRange(result.ExitCode, 2, int.MaxValue); | 143 | Assert.Equal((int)LinkerErrors.Ids.PayloadSharedWithBA, result.ExitCode); |
143 | } | 144 | } |
144 | } | 145 | } |
145 | 146 | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/BadInput/OrphanPayload.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/BadInput/OrphanPayload.wxs new file mode 100644 index 00000000..92a9602f --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/BadInput/OrphanPayload.wxs | |||
@@ -0,0 +1,11 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
3 | <Fragment> | ||
4 | <PackageGroup Id="BundlePackages"> | ||
5 | <PackageGroupRef Id="MinimalPackageGroup" /> | ||
6 | </PackageGroup> | ||
7 | <PayloadGroup Id="OrphanPayloads"> | ||
8 | <Payload Id="OrphanPayload" SourceFile="$(sys.SOURCEFILEPATH)" /> | ||
9 | </PayloadGroup> | ||
10 | </Fragment> | ||
11 | </Wix> | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/BadInput/PackageInMultipleContainers.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/BadInput/PackageInMultipleContainers.wxs new file mode 100644 index 00000000..a00874ce --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/BadInput/PackageInMultipleContainers.wxs | |||
@@ -0,0 +1,14 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
3 | <Fragment> | ||
4 | <PackageGroup Id="BundlePackages"> | ||
5 | <PackageGroupRef Id="MinimalPackageGroup" /> | ||
6 | </PackageGroup> | ||
7 | <Container Id="First"> | ||
8 | <PackageGroupRef Id="BundlePackages" /> | ||
9 | </Container> | ||
10 | <Container Id="Second"> | ||
11 | <PackageGroupRef Id="BundlePackages" /> | ||
12 | </Container> | ||
13 | </Fragment> | ||
14 | </Wix> | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/BadInput/UnscheduledPackage.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/BadInput/UnscheduledPackage.wxs index ab86982d..fc53c4a2 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/BadInput/UnscheduledPackage.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/BadInput/UnscheduledPackage.wxs | |||
@@ -2,15 +2,15 @@ | |||
2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | 2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> |
3 | <Fragment> | 3 | <Fragment> |
4 | <PackageGroup Id="BundlePackages"> | 4 | <PackageGroup Id="BundlePackages"> |
5 | <ExePackage Id="Auto1" SourceFile="burn.exe" CacheId="Auto1" /> | 5 | <ExePackage Id="Auto1" SourceFile="burn.exe" CacheId="Auto1" DetectCondition="none" /> |
6 | <ExePackage Id="Auto2" SourceFile="burn.exe" CacheId="Auto2" /> | 6 | <ExePackage Id="Auto2" SourceFile="burn.exe" CacheId="Auto2" DetectCondition="none" /> |
7 | </PackageGroup> | 7 | </PackageGroup> |
8 | <SetVariableRef Id="Dummy" /> | 8 | <SetVariableRef Id="Dummy" /> |
9 | </Fragment> | 9 | </Fragment> |
10 | <Fragment> | 10 | <Fragment> |
11 | <SetVariable Id="Dummy" Variable="Dummy" /> | 11 | <SetVariable Id="Dummy" Variable="Dummy" /> |
12 | <PackageGroup Id="Unscheduled"> | 12 | <PackageGroup Id="Unscheduled"> |
13 | <ExePackage Id="Unscheduled1" SourceFile="burn.exe" CacheId="Unscheduled1" /> | 13 | <ExePackage Id="Unscheduled1" SourceFile="burn.exe" CacheId="Unscheduled1" DetectCondition="none" /> |
14 | </PackageGroup> | 14 | </PackageGroup> |
15 | </Fragment> | 15 | </Fragment> |
16 | </Wix> | 16 | </Wix> |
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/BadInput/UnscheduledRollbackBoundary.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/BadInput/UnscheduledRollbackBoundary.wxs index 8015ed92..6cf8528e 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/BadInput/UnscheduledRollbackBoundary.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/BadInput/UnscheduledRollbackBoundary.wxs | |||
@@ -2,8 +2,8 @@ | |||
2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | 2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> |
3 | <Fragment> | 3 | <Fragment> |
4 | <PackageGroup Id="BundlePackages"> | 4 | <PackageGroup Id="BundlePackages"> |
5 | <ExePackage Id="Auto1" SourceFile="burn.exe" CacheId="Auto1" /> | 5 | <ExePackage Id="Auto1" SourceFile="burn.exe" CacheId="Auto1" DetectCondition="none" /> |
6 | <ExePackage Id="Auto2" SourceFile="burn.exe" CacheId="Auto2" /> | 6 | <ExePackage Id="Auto2" SourceFile="burn.exe" CacheId="Auto2" DetectCondition="none" /> |
7 | </PackageGroup> | 7 | </PackageGroup> |
8 | <SetVariableRef Id="Dummy" /> | 8 | <SetVariableRef Id="Dummy" /> |
9 | </Fragment> | 9 | </Fragment> |
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/Container/LayoutPayloadInContainer.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/Container/LayoutPayloadInContainer.wxs new file mode 100644 index 00000000..0c5f8c7e --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/Container/LayoutPayloadInContainer.wxs | |||
@@ -0,0 +1,28 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
3 | <Bundle Name="BurnBundle" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="{B5B23622-239B-4E3B-BDAB-67648CB975BF}"> | ||
4 | <BootstrapperApplication> | ||
5 | <BootstrapperApplicationDll SourceFile="fakeba.dll" /> | ||
6 | </BootstrapperApplication> | ||
7 | <Chain> | ||
8 | <PackageGroupRef Id="BundlePackages" /> | ||
9 | </Chain> | ||
10 | <PayloadGroupRef Id="Shared" /> | ||
11 | </Bundle> | ||
12 | <Fragment> | ||
13 | <PackageGroup Id="BundlePackages"> | ||
14 | <PackageGroupRef Id="FirstX64" /> | ||
15 | </PackageGroup> | ||
16 | <PackageGroup Id="FirstX64"> | ||
17 | <MsiPackage SourceFile="FirstX64.msi"> | ||
18 | <PayloadGroupRef Id="Shared" /> | ||
19 | </MsiPackage> | ||
20 | </PackageGroup> | ||
21 | <Container Id="FirstX64" Name="FirstX64" Type="detached"> | ||
22 | <PackageGroupRef Id="FirstX64" /> | ||
23 | </Container> | ||
24 | <PayloadGroup Id="Shared"> | ||
25 | <Payload Id="SharedPayload" SourceFile="$(sys.SOURCEFILEPATH)" /> | ||
26 | </PayloadGroup> | ||
27 | </Fragment> | ||
28 | </Wix> | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/Container/PayloadInMultipleContainers.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/Container/PayloadInMultipleContainers.wxs new file mode 100644 index 00000000..c7f549a3 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/Container/PayloadInMultipleContainers.wxs | |||
@@ -0,0 +1,28 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
3 | <Fragment> | ||
4 | <PackageGroup Id="BundlePackages"> | ||
5 | <PackageGroupRef Id="FirstX86" /> | ||
6 | <PackageGroupRef Id="FirstX64" /> | ||
7 | </PackageGroup> | ||
8 | <PackageGroup Id="FirstX86"> | ||
9 | <MsiPackage SourceFile="FirstX86.msi"> | ||
10 | <PayloadGroupRef Id="Shared" /> | ||
11 | </MsiPackage> | ||
12 | </PackageGroup> | ||
13 | <PackageGroup Id="FirstX64"> | ||
14 | <MsiPackage SourceFile="FirstX64.msi"> | ||
15 | <PayloadGroupRef Id="Shared" /> | ||
16 | </MsiPackage> | ||
17 | </PackageGroup> | ||
18 | <Container Id="FirstX86" Name="FirstX86" Type="detached"> | ||
19 | <PackageGroupRef Id="FirstX86" /> | ||
20 | </Container> | ||
21 | <Container Id="FirstX64" Name="FirstX64" Type="detached"> | ||
22 | <PackageGroupRef Id="FirstX64" /> | ||
23 | </Container> | ||
24 | <PayloadGroup Id="Shared"> | ||
25 | <Payload Id="SharedPayload" SourceFile="$(sys.SOURCEFILEPATH)" /> | ||
26 | </PayloadGroup> | ||
27 | </Fragment> | ||
28 | </Wix> | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/Payload/SharedBAAndPackagePayloadBundle.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/Payload/SharedBAAndPackagePayloadBundle.wxs index 4cfeb99f..5263cbd4 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/Payload/SharedBAAndPackagePayloadBundle.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/Payload/SharedBAAndPackagePayloadBundle.wxs | |||
@@ -2,7 +2,7 @@ | |||
2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | 2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> |
3 | <Fragment> | 3 | <Fragment> |
4 | <PackageGroup Id="BundlePackages"> | 4 | <PackageGroup Id="BundlePackages"> |
5 | <ExePackage SourceFile="burn.exe"> | 5 | <ExePackage SourceFile="burn.exe" DetectCondition="none"> |
6 | <PayloadGroupRef Id="Shared" /> | 6 | <PayloadGroupRef Id="Shared" /> |
7 | </ExePackage> | 7 | </ExePackage> |
8 | </PackageGroup> | 8 | </PackageGroup> |
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/SharedPayloadsBetweenPackages/SharedPayloadsBetweenPackages.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/SharedPayloadsBetweenPackages/SharedPayloadsBetweenPackages.wxs index 3457a3b7..f16fce0d 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/SharedPayloadsBetweenPackages/SharedPayloadsBetweenPackages.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/SharedPayloadsBetweenPackages/SharedPayloadsBetweenPackages.wxs | |||
@@ -2,10 +2,10 @@ | |||
2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | 2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> |
3 | <Fragment> | 3 | <Fragment> |
4 | <PackageGroup Id="BundlePackages"> | 4 | <PackageGroup Id="BundlePackages"> |
5 | <ExePackage SourceFile="C:\Windows\system32\credwiz.exe" Permanent="yes"> | 5 | <ExePackage SourceFile="C:\Windows\system32\credwiz.exe" Permanent="yes" DetectCondition="none"> |
6 | <PayloadGroupRef Id="SharedPayloads" /> | 6 | <PayloadGroupRef Id="SharedPayloads" /> |
7 | </ExePackage> | 7 | </ExePackage> |
8 | <ExePackage SourceFile="C:\Windows\system32\cscript.exe" Permanent="yes"> | 8 | <ExePackage SourceFile="C:\Windows\system32\cscript.exe" Permanent="yes" DetectCondition="none"> |
9 | <PayloadGroupRef Id="SharedPayloads" /> | 9 | <PayloadGroupRef Id="SharedPayloads" /> |
10 | </ExePackage> | 10 | </ExePackage> |
11 | </PackageGroup> | 11 | </PackageGroup> |