Add multiple attached containers error and empty container warning.
#6144
Sean Hall committed
Apr 22, 2021 at 17:30 UTC
e1e1af1d3940e983bc727bf91a0952840171a279
5 files changed
+41
-8
src/WixToolset.Core.Burn/Bind/BindBundleCommand.cs
+6
-1
@@ -452,7 +452,7 @@ namespace WixToolset.Core.Burn
452
WixBundleContainerSymbol uxContainer;
453
IEnumerable<WixBundlePayloadSymbol> uxPayloads;
454
{
455
- var command = new CreateNonUXContainers(this.BackendHelper, section, bundleApplicationDllSymbol, containers.Values, payloadSymbols, this.IntermediateFolder, layoutDirectory, this.DefaultCompressionLevel);
455
+ var command = new CreateNonUXContainers(this.BackendHelper, this.Messaging, bundleApplicationDllSymbol, containers.Values, payloadSymbols, this.IntermediateFolder, layoutDirectory, this.DefaultCompressionLevel);
456
command.Execute();
457
458
fileTransfers.AddRange(command.FileTransfers);
@@ -462,6 +462,11 @@ namespace WixToolset.Core.Burn
462
uxPayloads = command.UXContainerPayloads;
463
}
464
465
+ if (this.Messaging.EncounteredError)
466
+ {
467
+ return;
468
+ }
469
+
470
// Resolve the download URLs now that we have all of the containers and payloads calculated.
471
{
472
var command = new ResolveDownloadUrlsCommand(this.Messaging, this.BackendExtensions, containers.Values, payloadSymbols);
src/WixToolset.Core.Burn/Bundles/CreateNonUXContainers.cs
+20
-5
@@ -2,6 +2,7 @@
2
3
namespace WixToolset.Core.Burn.Bundles
4
{
5
+ using System;
6
using System.Collections.Generic;
7
using System.Diagnostics;
8
using System.IO;
@@ -14,10 +15,10 @@ namespace WixToolset.Core.Burn.Bundles
15
16
internal class CreateNonUXContainers
17
{
17
- public CreateNonUXContainers(IBackendHelper backendHelper, IntermediateSection section, WixBootstrapperApplicationDllSymbol bootstrapperApplicationDllSymbol, IEnumerable<WixBundleContainerSymbol> containerSymbols, Dictionary<string, WixBundlePayloadSymbol> payloadSymbols, string intermediateFolder, string layoutFolder, CompressionLevel? defaultCompressionLevel)
18
+ public CreateNonUXContainers(IBackendHelper backendHelper, IMessaging messaging, WixBootstrapperApplicationDllSymbol bootstrapperApplicationDllSymbol, IEnumerable<WixBundleContainerSymbol> containerSymbols, Dictionary<string, WixBundlePayloadSymbol> payloadSymbols, string intermediateFolder, string layoutFolder, CompressionLevel? defaultCompressionLevel)
19
{
20
this.BackendHelper = backendHelper;
20
- this.Section = section;
21
+ this.Messaging = messaging;
22
this.BootstrapperApplicationDllSymbol = bootstrapperApplicationDllSymbol;
23
this.Containers = containerSymbols;
24
this.PayloadSymbols = payloadSymbols;
@@ -38,7 +39,7 @@ namespace WixToolset.Core.Burn.Bundles
39
40
private IBackendHelper BackendHelper { get; }
41
41
- private IntermediateSection Section { get; }
42
+ private IMessaging Messaging { get; }
43
44
private WixBootstrapperApplicationDllSymbol BootstrapperApplicationDllSymbol { get; }
45
@@ -70,7 +71,7 @@ namespace WixToolset.Core.Burn.Bundles
71
{
72
if (containerId != BurnConstants.BurnDefaultAttachedContainerName)
73
{
73
- // TODO: display warning that we're ignoring container that ended up with no paylods in it.
74
+ this.Messaging.Write(BurnBackendWarnings.EmptyContainer(container.SourceLineNumbers, containerId));
75
}
76
}
77
else if (BurnConstants.BurnUXContainerName == containerId)
@@ -113,8 +114,22 @@ namespace WixToolset.Core.Burn.Bundles
114
container.AttachedContainerIndex = attachedContainerIndex;
115
++attachedContainerIndex;
116
}
117
+ }
118
+ }
119
117
- this.CreateContainer(container, containerPayloads);
120
+ foreach (var container in this.Containers.Where(c => !String.IsNullOrEmpty(c.WorkingPath) && c.Id.Id != BurnConstants.BurnUXContainerName))
121
+ {
122
+ if (container.Type == ContainerType.Attached && attachedContainerIndex > 2 && container.Id.Id != BurnConstants.BurnDefaultAttachedContainerName)
123
+ {
124
+ this.Messaging.Write(BurnBackendErrors.MultipleAttachedContainersUnsupported(container.SourceLineNumbers, container.Id.Id));
125
+ }
126
+ }
127
+
128
+ if (!this.Messaging.EncounteredError)
129
+ {
130
+ foreach (var container in this.Containers.Where(c => !String.IsNullOrEmpty(c.WorkingPath) && c.Id.Id != BurnConstants.BurnUXContainerName))
131
+ {
132
+ this.CreateContainer(container, payloadsByContainer[container.Id.Id]);
133
trackedFiles.Add(this.BackendHelper.TrackFile(container.WorkingPath, TrackedFileType.Temporary, container.SourceLineNumbers));
134
}
135
}
src/WixToolset.Core.Burn/BurnBackendErrors.cs
+6
@@ -36,6 +36,11 @@ namespace WixToolset.Core.Burn
36
return Message(sourceLineNumbers, Ids.ExternalPayloadCollision2, "The location of the symbol related to the previous error.");
37
}
38
39
+ public static Message MultipleAttachedContainersUnsupported(SourceLineNumber sourceLineNumbers, string containerId)
40
+ {
41
+ return Message(sourceLineNumbers, Ids.MultipleAttachedContainersUnsupported, "Bundles don't currently support having more than one attached container. Either remove all authored attached containers to use the default attached container, or make sure all compressed payloads are included in this Container '{0}'.", containerId);
42
+ }
43
+
44
public static Message PackageCachePayloadCollision(SourceLineNumber sourceLineNumbers, string payloadId, string payloadName, string packageId)
45
{
46
return Message(sourceLineNumbers, Ids.PackageCachePayloadCollision, "The Payload '{0}' has a duplicate Name '{1}' in package '{2}'. When caching the package, the file will get overwritten.", payloadId, payloadName, packageId);
@@ -61,6 +66,7 @@ namespace WixToolset.Core.Burn
66
ExternalPayloadCollision2 = 8005,
67
PackageCachePayloadCollision = 8006,
68
PackageCachePayloadCollision2 = 8007,
69
+ MultipleAttachedContainersUnsupported = 8008,
70
}
71
}
72
}
src/WixToolset.Core.Burn/BurnBackendWarnings.cs
+6
@@ -16,6 +16,11 @@ namespace WixToolset.Core.Burn
16
return Message(sourceLineNumbers, Ids.AttachedContainerPayloadCollision2, "The location of the payload related to the previous error.");
17
}
18
19
+ public static Message EmptyContainer(SourceLineNumber sourceLineNumbers, string containerId)
20
+ {
21
+ return Message(sourceLineNumbers, Ids.EmptyContainer, "The Container '{0}' is being ignored because it doesn't have any payloads.", containerId);
22
+ }
23
+
24
private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args)
25
{
26
return new Message(sourceLineNumber, MessageLevel.Warning, (int)id, format, args);
@@ -25,6 +30,7 @@ namespace WixToolset.Core.Burn
30
{
31
AttachedContainerPayloadCollision = 8500,
32
AttachedContainerPayloadCollision2 = 8501,
33
+ EmptyContainer = 8502,
34
}
35
}
36
}
src/test/WixToolsetTest.CoreIntegration/ContainerFixture.cs
+3
-2
@@ -8,6 +8,7 @@ namespace WixToolsetTest.CoreIntegration
8
using System.Linq;
9
using System.Xml;
10
using WixBuildTools.TestSupport;
11
+ using WixToolset.Core.Burn;
12
using WixToolset.Core.TestPackage;
13
using WixToolset.Data;
14
using WixToolset.Data.Symbols;
@@ -155,7 +156,7 @@ namespace WixToolsetTest.CoreIntegration
156
}
157
}
158
158
- [Fact(Skip = "https://github.com/wixtoolset/issues/issues/6144")]
159
+ [Fact]
160
public void MultipleAttachedContainersAreNotCurrentlySupported()
161
{
162
var folder = TestData.Get(@"TestData");
@@ -206,7 +207,7 @@ namespace WixToolsetTest.CoreIntegration
207
"-o", bundlePath
208
});
209
209
- Assert.InRange(result.ExitCode, 2, Int32.MaxValue);
210
+ Assert.Equal((int)BurnBackendErrors.Ids.MultipleAttachedContainersUnsupported, result.ExitCode);
211
}
212
}
213
}