aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/WixToolset.Core.Burn/Bind/BindBundleCommand.cs27
-rw-r--r--src/WixToolset.Core.Burn/BurnBackendErrors.cs16
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/BundleFixture.cs4
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/TestData/BadInput/DuplicateCacheIds.wxs7
4 files changed, 43 insertions, 11 deletions
diff --git a/src/WixToolset.Core.Burn/Bind/BindBundleCommand.cs b/src/WixToolset.Core.Burn/Bind/BindBundleCommand.cs
index 5ddb6be1..37fc17f9 100644
--- a/src/WixToolset.Core.Burn/Bind/BindBundleCommand.cs
+++ b/src/WixToolset.Core.Burn/Bind/BindBundleCommand.cs
@@ -359,7 +359,6 @@ namespace WixToolset.Core.Burn
359 this.BackendHelper.ResolveDelayedFields(this.DelayedFields, variableCache); 359 this.BackendHelper.ResolveDelayedFields(this.DelayedFields, variableCache);
360 } 360 }
361 361
362 Dictionary<string, WixDependencyProviderSymbol> dependencySymbolsByKey;
363 { 362 {
364 var command = new ProcessDependencyProvidersCommand(this.Messaging, section, facades); 363 var command = new ProcessDependencyProvidersCommand(this.Messaging, section, facades);
365 command.Execute(); 364 command.Execute();
@@ -368,7 +367,6 @@ namespace WixToolset.Core.Burn
368 { 367 {
369 bundleSymbol.ProviderKey = command.BundleProviderKey; // set the overridable bundle provider key. 368 bundleSymbol.ProviderKey = command.BundleProviderKey; // set the overridable bundle provider key.
370 } 369 }
371 dependencySymbolsByKey = command.DependencySymbolsByKey;
372 } 370 }
373 371
374 // Update the bundle per-machine/per-user scope based on the chained packages. 372 // Update the bundle per-machine/per-user scope based on the chained packages.
@@ -381,6 +379,13 @@ namespace WixToolset.Core.Burn
381 command.Execute(); 379 command.Execute();
382 } 380 }
383 381
382 this.DetectDuplicateCacheIds(facades);
383
384 if (this.Messaging.EncounteredError)
385 {
386 return;
387 }
388
384 // Give the extension one last hook before generating the output files. 389 // Give the extension one last hook before generating the output files.
385 foreach (var extension in this.BackendExtensions) 390 foreach (var extension in this.BackendExtensions)
386 { 391 {
@@ -581,6 +586,24 @@ namespace WixToolset.Core.Burn
581 } 586 }
582 } 587 }
583 588
589 private void DetectDuplicateCacheIds(IDictionary<string, PackageFacade> facades)
590 {
591 var duplicateCacheIdDetector = new Dictionary<string, WixBundlePackageSymbol>();
592
593 foreach (var facade in facades.Values)
594 {
595 if (duplicateCacheIdDetector.TryGetValue(facade.PackageSymbol.CacheId, out var collisionPackage))
596 {
597 this.Messaging.Write(BurnBackendErrors.DuplicateCacheIds(collisionPackage.SourceLineNumbers, facade.PackageSymbol.CacheId));
598 this.Messaging.Write(BurnBackendErrors.DuplicateCacheIds2(facade.PackageSymbol.SourceLineNumbers, facade.PackageSymbol.CacheId));
599 }
600 else
601 {
602 duplicateCacheIdDetector.Add(facade.PackageSymbol.CacheId, facade.PackageSymbol);
603 }
604 }
605 }
606
584 private IEnumerable<T> GetRequiredSymbols<T>() where T : IntermediateSymbol 607 private IEnumerable<T> GetRequiredSymbols<T>() where T : IntermediateSymbol
585 { 608 {
586 var symbols = this.Output.Sections.Single().Symbols.OfType<T>().ToList(); 609 var symbols = this.Output.Sections.Single().Symbols.OfType<T>().ToList();
diff --git a/src/WixToolset.Core.Burn/BurnBackendErrors.cs b/src/WixToolset.Core.Burn/BurnBackendErrors.cs
index 106c3b31..4c846e8a 100644
--- a/src/WixToolset.Core.Burn/BurnBackendErrors.cs
+++ b/src/WixToolset.Core.Burn/BurnBackendErrors.cs
@@ -6,10 +6,15 @@ namespace WixToolset.Core.Burn
6 6
7 internal static class BurnBackendErrors 7 internal static class BurnBackendErrors
8 { 8 {
9 //public static Message ReplaceThisWithTheFirstError(SourceLineNumber sourceLineNumbers) 9 public static Message DuplicateCacheIds(SourceLineNumber originalLineNumber, string cacheId)
10 //{ 10 {
11 // return Message(sourceLineNumbers, Ids.ReplaceThisWithTheFirstError, "format string", arg1, arg2); 11 return Message(originalLineNumber, Ids.DuplicateCacheIds, "The cache id '{0}' has been duplicated as indicated in the following message.", cacheId);
12 //} 12 }
13
14 public static Message DuplicateCacheIds2(SourceLineNumber duplicateLineNumber, string cacheId)
15 {
16 return Message(duplicateLineNumber, Ids.DuplicateCacheIds2, "Each cache id must be unique. '{0}' has been used before as indicated in the previous message.", cacheId);
17 }
13 18
14 private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args) 19 private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args)
15 { 20 {
@@ -18,7 +23,8 @@ namespace WixToolset.Core.Burn
18 23
19 public enum Ids 24 public enum Ids
20 { 25 {
21 // ReplaceThisWithTheFirstError = 8000, 26 DuplicateCacheIds = 8000,
27 DuplicateCacheIds2 = 8001,
22 } 28 }
23 } 29 }
24} 30}
diff --git a/src/test/WixToolsetTest.CoreIntegration/BundleFixture.cs b/src/test/WixToolsetTest.CoreIntegration/BundleFixture.cs
index 38554b70..d121da0f 100644
--- a/src/test/WixToolsetTest.CoreIntegration/BundleFixture.cs
+++ b/src/test/WixToolsetTest.CoreIntegration/BundleFixture.cs
@@ -280,7 +280,7 @@ namespace WixToolsetTest.CoreIntegration
280 } 280 }
281 } 281 }
282 282
283 [Fact(Skip = "https://github.com/wixtoolset/issues/issues/4628")] 283 [Fact]
284 public void CantBuildWithDuplicateCacheIds() 284 public void CantBuildWithDuplicateCacheIds()
285 { 285 {
286 var folder = TestData.Get(@"TestData"); 286 var folder = TestData.Get(@"TestData");
@@ -302,7 +302,7 @@ namespace WixToolsetTest.CoreIntegration
302 "-o", exePath, 302 "-o", exePath,
303 }); 303 });
304 304
305 Assert.InRange(result.ExitCode, 2, Int32.MaxValue); 305 Assert.Equal(8001, result.ExitCode);
306 } 306 }
307 } 307 }
308 308
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/BadInput/DuplicateCacheIds.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/BadInput/DuplicateCacheIds.wxs
index 5c58ef50..0c350042 100644
--- a/src/test/WixToolsetTest.CoreIntegration/TestData/BadInput/DuplicateCacheIds.wxs
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/BadInput/DuplicateCacheIds.wxs
@@ -2,8 +2,11 @@
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="Manual1" SourceFile="burn.exe" Name="manual1\burn.exe" CacheId="Manual" /> 5 <ExePackage Id="Manual1" SourceFile="burn.exe" Name="manual1\burn.exe" DetectCondition="test" CacheId="!(wix.WixVariable1)" />
6 <ExePackage Id="Manual2" SourceFile="burn.exe" Name="manual2\burn.exe" CacheId="Manual" /> 6 <ExePackage Id="Manual2" SourceFile="burn.exe" Name="manual2\burn.exe" DetectCondition="test" CacheId="!(wix.WixVariable2)" />
7 </PackageGroup> 7 </PackageGroup>
8
9 <WixVariable Id="WixVariable1" Value="CollidingCacheId" />
10 <WixVariable Id="WixVariable2" Value="CollidingCacheId" />
8 </Fragment> 11 </Fragment>
9</Wix> 12</Wix>