Clean up error message when BA is missing.
Fixes https://github.com/wixtoolset/issues/issues/6852.
Bob Arnson committed
Aug 14, 2022 at 23:56 UTC
da5cc586114e537461b239a882c5bbea470d812d
4 files changed
+47
-14
src/api/wix/WixToolset.Data/ErrorMessages.cs
+2
-2
@@ -1425,9 +1425,9 @@ namespace WixToolset.Data
1425
return Message(sourceLineNumbers, Ids.MergePlatformMismatch, "'{0}' is a 64-bit merge module but the product consuming it is 32-bit. 32-bit products can consume only 32-bit merge modules.", mergeModuleFile);
1426
}
1427
1428
- public static Message MissingBundleInformation(string data)
1428
+ public static Message MissingBundleInformation(string friendlyName)
1429
{
1430
- return Message(null, Ids.MissingBundleInformation, "The Bundle is missing '{0}' data, and cannot continue.", data);
1430
+ return Message(null, Ids.MissingBundleInformation, "The Bundle is missing {0} data, and cannot continue.", friendlyName);
1431
}
1432
1433
public static Message MissingBundleSearch(SourceLineNumber sourceLineNumbers, string searchId)
src/wix/WixToolset.Core.Burn/Bind/BindBundleCommand.cs
+6
-12
@@ -96,9 +96,7 @@ namespace WixToolset.Core.Burn
96
var wixGroupSymbols = this.GetRequiredSymbols<WixGroupSymbol>();
97
98
// Ensure there is one and only one WixBundleSymbol.
99
- // The compiler and linker behavior should have colluded to get
100
- // this behavior.
101
- var bundleSymbol = this.GetSingleSymbol<WixBundleSymbol>();
99
+ var bundleSymbol = this.GetSingleSymbol<WixBundleSymbol>("bundle");
100
101
bundleSymbol.ProviderKey = bundleSymbol.BundleId = Guid.NewGuid().ToString("B").ToUpperInvariant();
102
@@ -107,14 +105,10 @@ namespace WixToolset.Core.Burn
105
this.NormalizeRelatedBundles(bundleSymbol, section);
106
107
// Ensure there is one and only one WixBootstrapperApplicationDllSymbol.
110
- // The compiler and linker behavior should have colluded to get
111
- // this behavior.
112
- var bundleApplicationDllSymbol = this.GetSingleSymbol<WixBootstrapperApplicationDllSymbol>();
108
+ var bundleApplicationDllSymbol = this.GetSingleSymbol<WixBootstrapperApplicationDllSymbol>("bootstrapper application");
109
110
// Ensure there is one and only one WixChainSymbol.
115
- // The compiler and linker behavior should have colluded to get
116
- // this behavior.
117
- var chainSymbol = this.GetSingleSymbol<WixChainSymbol>();
111
+ var chainSymbol = this.GetSingleSymbol<WixChainSymbol>("package chain");
112
113
if (this.Messaging.EncounteredError)
114
{
@@ -317,7 +311,7 @@ namespace WixToolset.Core.Burn
311
if (0 == uxPayloadIndex)
312
{
313
// If we didn't get any UX payloads, it's an error!
320
- throw new WixException(ErrorMessages.MissingBundleInformation("BootstrapperApplication"));
314
+ throw new WixException(ErrorMessages.MissingBundleInformation("bootstrapper application"));
315
}
316
317
// Give the embedded payloads without an embedded id yet an embedded id.
@@ -691,13 +685,13 @@ namespace WixToolset.Core.Burn
685
return symbols;
686
}
687
694
- private T GetSingleSymbol<T>() where T : IntermediateSymbol
688
+ private T GetSingleSymbol<T>(string elementName) where T : IntermediateSymbol
689
{
690
var symbols = this.Output.Sections.Single().Symbols.OfType<T>().ToList();
691
692
if (1 != symbols.Count)
693
{
700
- throw new WixException(ErrorMessages.MissingBundleInformation(typeof(T).Name));
694
+ throw new WixException(ErrorMessages.MissingBundleInformation(elementName));
695
}
696
697
return symbols[0];
src/wix/test/WixToolsetTest.CoreIntegration/BundleFixture.cs
+32
@@ -730,5 +730,37 @@ namespace WixToolsetTest.CoreIntegration
730
Assert.Equal(7004, result.ExitCode);
731
}
732
}
733
+
734
+ [Fact]
735
+ public void CannotBuildWithMissingBootstrapperApplication()
736
+ {
737
+ var folder = TestData.Get(@"TestData");
738
+
739
+ using (var fs = new DisposableFileSystem())
740
+ {
741
+ var baseFolder = fs.GetFolder();
742
+ var intermediateFolder = Path.Combine(baseFolder, "obj");
743
+ var exePath = Path.Combine(baseFolder, @"bin\test.exe");
744
+
745
+ try
746
+ {
747
+ WixRunner.Execute(new[]
748
+ {
749
+ "build",
750
+ Path.Combine(folder, "BundleWithInvalid", "BundleWithMissingBA.wxs"),
751
+ "-bindpath", Path.Combine(folder, ".Data"),
752
+ "-intermediateFolder", intermediateFolder,
753
+ "-o", exePath,
754
+ });
755
+ }
756
+ catch (WixException we)
757
+ {
758
+ Assert.Equal(341, we.Error.Id);
759
+ return;
760
+ }
761
+
762
+ Assert.False(true, "Expected exception not accepted.");
763
+ }
764
+ }
765
}
766
}
src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleWithInvalid/BundleWithMissingBA.wxs
new
+7
@@ -0,0 +1,7 @@
1
+<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2
+ <Bundle Name="BundleWithMissingBA" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="B94478B1-E1F3-4700-9CE8-6AA090854AEC">
3
+ <Chain>
4
+ <ExePackage DetectCondition="DetectedSomething" UninstallArguments="-uninstall" SourceFile="burn.exe" />
5
+ </Chain>
6
+ </Bundle>
7
+</Wix>