diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2023-01-18 19:03:44 -0600 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2023-01-18 20:07:03 -0600 |
commit | 7a0aa56131ba7fa3b63788908c164d0f8118e3fc (patch) | |
tree | de06072b4bcf95c77afbae6efbf31df83f2848e0 | |
parent | d180bc6df297422f189ffd08a0dd558bfbeba1ca (diff) | |
download | wix-7a0aa56131ba7fa3b63788908c164d0f8118e3fc.tar.gz wix-7a0aa56131ba7fa3b63788908c164d0f8118e3fc.tar.bz2 wix-7a0aa56131ba7fa3b63788908c164d0f8118e3fc.zip |
Improve error messages from BalBurnBackendExtension.
-rw-r--r-- | src/ext/Bal/test/WixToolsetTest.Bal/BalExtensionFixture.cs | 2 | ||||
-rw-r--r-- | src/ext/Bal/wixext/BalBurnBackendExtension.cs | 45 | ||||
-rw-r--r-- | src/ext/Bal/wixext/BalCompiler.cs | 15 | ||||
-rw-r--r-- | src/ext/Bal/wixext/BalErrors.cs | 14 | ||||
-rw-r--r-- | src/ext/Bal/wixext/Symbols/BalSymbolDefinitions.cs | 6 | ||||
-rw-r--r-- | src/ext/Bal/wixext/Symbols/WixBalBootstrapperApplicationSymbol.cs | 56 |
6 files changed, 105 insertions, 33 deletions
diff --git a/src/ext/Bal/test/WixToolsetTest.Bal/BalExtensionFixture.cs b/src/ext/Bal/test/WixToolsetTest.Bal/BalExtensionFixture.cs index 57dbda9c..2e60e2c0 100644 --- a/src/ext/Bal/test/WixToolsetTest.Bal/BalExtensionFixture.cs +++ b/src/ext/Bal/test/WixToolsetTest.Bal/BalExtensionFixture.cs | |||
@@ -204,7 +204,7 @@ namespace WixToolsetTest.Bal | |||
204 | }); | 204 | }); |
205 | WixAssert.CompareLineByLine(new[] | 205 | WixAssert.CompareLineByLine(new[] |
206 | { | 206 | { |
207 | "The BA's entry point DLL must have bal:BAFactoryAssembly=\"yes\" when using the DotNetCoreBootstrapperApplicationHost.", | 207 | "When using DotNetCoreBootstrapperApplicationHost, the Payload element for the BA's entry point DLL must have bal:BAFactoryAssembly=\"yes\".", |
208 | }, compileResult.Messages.Select(x => x.ToString()).ToArray()); | 208 | }, compileResult.Messages.Select(x => x.ToString()).ToArray()); |
209 | Assert.Equal(6818, compileResult.ExitCode); | 209 | Assert.Equal(6818, compileResult.ExitCode); |
210 | 210 | ||
diff --git a/src/ext/Bal/wixext/BalBurnBackendExtension.cs b/src/ext/Bal/wixext/BalBurnBackendExtension.cs index be294131..0293b236 100644 --- a/src/ext/Bal/wixext/BalBurnBackendExtension.cs +++ b/src/ext/Bal/wixext/BalBurnBackendExtension.cs | |||
@@ -86,6 +86,11 @@ namespace WixToolset.Bal | |||
86 | 86 | ||
87 | return true; | 87 | return true; |
88 | } | 88 | } |
89 | else if (symbol is WixBalBootstrapperApplicationSymbol) | ||
90 | { | ||
91 | // This symbol is only for the processing in SymbolsFinalized. | ||
92 | return true; | ||
93 | } | ||
89 | else | 94 | else |
90 | { | 95 | { |
91 | return base.TryProcessSymbol(section, symbol); | 96 | return base.TryProcessSymbol(section, symbol); |
@@ -100,28 +105,33 @@ namespace WixToolset.Bal | |||
100 | this.VerifyDisplayInternalUICondition(section); | 105 | this.VerifyDisplayInternalUICondition(section); |
101 | this.VerifyOverridableVariables(section); | 106 | this.VerifyOverridableVariables(section); |
102 | 107 | ||
103 | var baSymbol = section.Symbols.OfType<WixBootstrapperApplicationDllSymbol>().SingleOrDefault(); | 108 | var balBaSymbol = section.Symbols.OfType<WixBalBootstrapperApplicationSymbol>().SingleOrDefault(); |
104 | var baId = baSymbol?.Id?.Id; | 109 | if (balBaSymbol == null) |
105 | if (null == baId) | ||
106 | { | 110 | { |
107 | return; | 111 | return; |
108 | } | 112 | } |
109 | 113 | ||
110 | var isIuiBA = baId.StartsWith("WixInternalUIBootstrapperApplication"); | 114 | var isIuiBA = balBaSymbol.Type == WixBalBootstrapperApplicationType.InternalUi; |
111 | var isStdBA = baId.StartsWith("WixStandardBootstrapperApplication"); | 115 | var isStdBA = balBaSymbol.Type == WixBalBootstrapperApplicationType.Standard; |
112 | var isMBA = baId.StartsWith("WixManagedBootstrapperApplicationHost"); | 116 | var isMBA = balBaSymbol.Type == WixBalBootstrapperApplicationType.ManagedHost; |
113 | var isDNC = baId.StartsWith("WixDotNetCoreBootstrapperApplicationHost"); | 117 | var isDNC = balBaSymbol.Type == WixBalBootstrapperApplicationType.DotNetCoreHost; |
114 | var isSCD = isDNC && this.VerifySCD(section); | 118 | var isSCD = isDNC && this.VerifySCD(section); |
115 | 119 | ||
120 | |||
121 | if (!isIuiBA && !isStdBA && !isMBA && !isDNC) | ||
122 | { | ||
123 | throw new WixException($"Invalid WixBalBootstrapperApplicationType: '{balBaSymbol.Type}'"); | ||
124 | } | ||
125 | |||
116 | if (isIuiBA) | 126 | if (isIuiBA) |
117 | { | 127 | { |
118 | // This needs to happen before VerifyPrereqPackages because it can add prereq packages. | 128 | // This needs to happen before VerifyPrereqPackages because it can add prereq packages. |
119 | this.VerifyPrimaryPackages(section); | 129 | this.VerifyPrimaryPackages(section, balBaSymbol.SourceLineNumbers); |
120 | } | 130 | } |
121 | 131 | ||
122 | if (isDNC) | 132 | if (isDNC) |
123 | { | 133 | { |
124 | this.FinalizeBAFactorySymbol(section, baSymbol); | 134 | this.FinalizeBAFactorySymbol(section, balBaSymbol.SourceLineNumbers); |
125 | } | 135 | } |
126 | 136 | ||
127 | if (isIuiBA || isStdBA || isMBA || isDNC) | 137 | if (isIuiBA || isStdBA || isMBA || isDNC) |
@@ -131,16 +141,16 @@ namespace WixToolset.Bal | |||
131 | 141 | ||
132 | if (isIuiBA || isMBA || (isDNC && !isSCD)) | 142 | if (isIuiBA || isMBA || (isDNC && !isSCD)) |
133 | { | 143 | { |
134 | this.VerifyPrereqPackages(section, isDNC, isIuiBA); | 144 | this.VerifyPrereqPackages(section, balBaSymbol.SourceLineNumbers, isDNC, isIuiBA); |
135 | } | 145 | } |
136 | } | 146 | } |
137 | 147 | ||
138 | private void FinalizeBAFactorySymbol(IntermediateSection section, WixBootstrapperApplicationDllSymbol baSymbol) | 148 | private void FinalizeBAFactorySymbol(IntermediateSection section, SourceLineNumber baSourceLineNumbers) |
139 | { | 149 | { |
140 | var factorySymbol = section.Symbols.OfType<WixBalBAFactoryAssemblySymbol>().SingleOrDefault(); | 150 | var factorySymbol = section.Symbols.OfType<WixBalBAFactoryAssemblySymbol>().SingleOrDefault(); |
141 | if (null == factorySymbol) | 151 | if (null == factorySymbol) |
142 | { | 152 | { |
143 | this.Messaging.Write(BalErrors.MissingDNCBAFactoryAssembly(baSymbol.SourceLineNumbers)); | 153 | this.Messaging.Write(BalErrors.MissingDNCBAFactoryAssembly(baSourceLineNumbers)); |
144 | return; | 154 | return; |
145 | } | 155 | } |
146 | 156 | ||
@@ -149,8 +159,7 @@ namespace WixToolset.Bal | |||
149 | .SingleOrDefault(); | 159 | .SingleOrDefault(); |
150 | if (null == factoryPayloadSymbol) | 160 | if (null == factoryPayloadSymbol) |
151 | { | 161 | { |
152 | this.Messaging.Write(BalErrors.MissingDNCBAFactoryAssembly(factorySymbol.SourceLineNumbers)); | 162 | throw new WixException($"Missing payload symbol with id: 'factorySymbol.PayloadId'"); |
153 | return; | ||
154 | } | 163 | } |
155 | 164 | ||
156 | factorySymbol.FilePath = factoryPayloadSymbol.Name; | 165 | factorySymbol.FilePath = factoryPayloadSymbol.Name; |
@@ -216,7 +225,7 @@ namespace WixToolset.Bal | |||
216 | } | 225 | } |
217 | } | 226 | } |
218 | 227 | ||
219 | private void VerifyPrimaryPackages(IntermediateSection section) | 228 | private void VerifyPrimaryPackages(IntermediateSection section, SourceLineNumber baSourceLineNumbers) |
220 | { | 229 | { |
221 | WixBalPackageInfoSymbol defaultPrimaryPackage = null; | 230 | WixBalPackageInfoSymbol defaultPrimaryPackage = null; |
222 | WixBalPackageInfoSymbol x86PrimaryPackage = null; | 231 | WixBalPackageInfoSymbol x86PrimaryPackage = null; |
@@ -398,7 +407,7 @@ namespace WixToolset.Bal | |||
398 | } | 407 | } |
399 | else if (defaultPrimaryPackage == null) | 408 | else if (defaultPrimaryPackage == null) |
400 | { | 409 | { |
401 | this.Messaging.Write(BalErrors.MissingIUIPrimaryPackage()); | 410 | this.Messaging.Write(BalErrors.MissingIUIPrimaryPackage(baSourceLineNumbers)); |
402 | } | 411 | } |
403 | else | 412 | else |
404 | { | 413 | { |
@@ -467,12 +476,12 @@ namespace WixToolset.Bal | |||
467 | } | 476 | } |
468 | } | 477 | } |
469 | 478 | ||
470 | private void VerifyPrereqPackages(IntermediateSection section, bool isDNC, bool isIuiBA) | 479 | private void VerifyPrereqPackages(IntermediateSection section, SourceLineNumber baSourceLineNumbers, bool isDNC, bool isIuiBA) |
471 | { | 480 | { |
472 | var prereqInfoSymbols = section.Symbols.OfType<WixMbaPrereqInformationSymbol>().ToList(); | 481 | var prereqInfoSymbols = section.Symbols.OfType<WixMbaPrereqInformationSymbol>().ToList(); |
473 | if (!isIuiBA && prereqInfoSymbols.Count == 0) | 482 | if (!isIuiBA && prereqInfoSymbols.Count == 0) |
474 | { | 483 | { |
475 | var message = isDNC ? BalErrors.MissingDNCPrereq() : BalErrors.MissingMBAPrereq(); | 484 | var message = isDNC ? BalErrors.MissingDNCPrereq(baSourceLineNumbers) : BalErrors.MissingMBAPrereq(baSourceLineNumbers); |
476 | this.Messaging.Write(message); | 485 | this.Messaging.Write(message); |
477 | return; | 486 | return; |
478 | } | 487 | } |
diff --git a/src/ext/Bal/wixext/BalCompiler.cs b/src/ext/Bal/wixext/BalCompiler.cs index bd2fb4a2..731943ee 100644 --- a/src/ext/Bal/wixext/BalCompiler.cs +++ b/src/ext/Bal/wixext/BalCompiler.cs | |||
@@ -581,7 +581,7 @@ namespace WixToolset.Bal | |||
581 | break; | 581 | break; |
582 | } | 582 | } |
583 | 583 | ||
584 | this.CreateBARef(section, sourceLineNumbers, node, baId); | 584 | this.CreateBARef(section, sourceLineNumbers, node, baId, WixBalBootstrapperApplicationType.InternalUi); |
585 | } | 585 | } |
586 | } | 586 | } |
587 | 587 | ||
@@ -860,7 +860,7 @@ namespace WixToolset.Bal | |||
860 | break; | 860 | break; |
861 | } | 861 | } |
862 | 862 | ||
863 | this.CreateBARef(section, sourceLineNumbers, node, baId); | 863 | this.CreateBARef(section, sourceLineNumbers, node, baId, WixBalBootstrapperApplicationType.Standard); |
864 | } | 864 | } |
865 | } | 865 | } |
866 | 866 | ||
@@ -963,7 +963,7 @@ namespace WixToolset.Bal | |||
963 | break; | 963 | break; |
964 | } | 964 | } |
965 | 965 | ||
966 | this.CreateBARef(section, sourceLineNumbers, node, baId); | 966 | this.CreateBARef(section, sourceLineNumbers, node, baId, WixBalBootstrapperApplicationType.ManagedHost); |
967 | 967 | ||
968 | if (alwaysInstallPrereqs) | 968 | if (alwaysInstallPrereqs) |
969 | { | 969 | { |
@@ -1086,7 +1086,7 @@ namespace WixToolset.Bal | |||
1086 | break; | 1086 | break; |
1087 | } | 1087 | } |
1088 | 1088 | ||
1089 | this.CreateBARef(section, sourceLineNumbers, node, baId); | 1089 | this.CreateBARef(section, sourceLineNumbers, node, baId, WixBalBootstrapperApplicationType.DotNetCoreHost); |
1090 | 1090 | ||
1091 | if (alwaysInstallPrereqs) | 1091 | if (alwaysInstallPrereqs) |
1092 | { | 1092 | { |
@@ -1098,7 +1098,7 @@ namespace WixToolset.Bal | |||
1098 | } | 1098 | } |
1099 | } | 1099 | } |
1100 | 1100 | ||
1101 | private void CreateBARef(IntermediateSection section, SourceLineNumber sourceLineNumbers, XElement node, string name) | 1101 | private void CreateBARef(IntermediateSection section, SourceLineNumber sourceLineNumbers, XElement node, string name, WixBalBootstrapperApplicationType baType) |
1102 | { | 1102 | { |
1103 | var id = this.ParseHelper.CreateIdentifierValueFromPlatform(name, this.Context.Platform, BurnPlatforms.X86 | BurnPlatforms.X64 | BurnPlatforms.ARM64); | 1103 | var id = this.ParseHelper.CreateIdentifierValueFromPlatform(name, this.Context.Platform, BurnPlatforms.X86 | BurnPlatforms.X64 | BurnPlatforms.ARM64); |
1104 | if (id == null) | 1104 | if (id == null) |
@@ -1109,6 +1109,11 @@ namespace WixToolset.Bal | |||
1109 | if (!this.Messaging.EncounteredError) | 1109 | if (!this.Messaging.EncounteredError) |
1110 | { | 1110 | { |
1111 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.WixBootstrapperApplication, id); | 1111 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.WixBootstrapperApplication, id); |
1112 | |||
1113 | section.AddSymbol(new WixBalBootstrapperApplicationSymbol(sourceLineNumbers) | ||
1114 | { | ||
1115 | Type = baType, | ||
1116 | }); | ||
1112 | } | 1117 | } |
1113 | } | 1118 | } |
1114 | } | 1119 | } |
diff --git a/src/ext/Bal/wixext/BalErrors.cs b/src/ext/Bal/wixext/BalErrors.cs index 2548b279..7fbccecb 100644 --- a/src/ext/Bal/wixext/BalErrors.cs +++ b/src/ext/Bal/wixext/BalErrors.cs | |||
@@ -45,22 +45,22 @@ namespace WixToolset.Bal | |||
45 | 45 | ||
46 | public static Message MissingDNCBAFactoryAssembly(SourceLineNumber sourceLineNumbers) | 46 | public static Message MissingDNCBAFactoryAssembly(SourceLineNumber sourceLineNumbers) |
47 | { | 47 | { |
48 | return Message(sourceLineNumbers, Ids.MissingDNCBAFactoryAssembly, "The BA's entry point DLL must have bal:BAFactoryAssembly=\"yes\" when using the DotNetCoreBootstrapperApplicationHost."); | 48 | return Message(sourceLineNumbers, Ids.MissingDNCBAFactoryAssembly, "When using DotNetCoreBootstrapperApplicationHost, the Payload element for the BA's entry point DLL must have bal:BAFactoryAssembly=\"yes\"."); |
49 | } | 49 | } |
50 | 50 | ||
51 | public static Message MissingDNCPrereq() | 51 | public static Message MissingDNCPrereq(SourceLineNumber sourceLineNumbers) |
52 | { | 52 | { |
53 | return Message(null, Ids.MissingDNCPrereq, "There must be at least one package with bal:PrereqPackage=\"yes\" when using the DotNetCoreBootstrapperApplicationHost with SelfContainedDeployment set to \"no\"."); | 53 | return Message(sourceLineNumbers, Ids.MissingDNCPrereq, "There must be at least one package with bal:PrereqPackage=\"yes\" when using the DotNetCoreBootstrapperApplicationHost with SelfContainedDeployment set to \"no\"."); |
54 | } | 54 | } |
55 | 55 | ||
56 | public static Message MissingIUIPrimaryPackage() | 56 | public static Message MissingIUIPrimaryPackage(SourceLineNumber sourceLineNumbers) |
57 | { | 57 | { |
58 | return Message(null, Ids.MissingIUIPrimaryPackage, "When using WixInternalUIBootstrapperApplication, there must be one package with bal:PrimaryPackageType=\"default\"."); | 58 | return Message(sourceLineNumbers, Ids.MissingIUIPrimaryPackage, "When using WixInternalUIBootstrapperApplication, there must be one package with bal:PrimaryPackageType=\"default\"."); |
59 | } | 59 | } |
60 | 60 | ||
61 | public static Message MissingMBAPrereq() | 61 | public static Message MissingMBAPrereq(SourceLineNumber sourceLineNumbers) |
62 | { | 62 | { |
63 | return Message(null, Ids.MissingMBAPrereq, "There must be at least one package with bal:PrereqPackage=\"yes\" when using the ManagedBootstrapperApplicationHost.\nThis is typically done by using the WixNetFxExtension and referencing one of the NetFxAsPrereq package groups."); | 63 | return Message(sourceLineNumbers, Ids.MissingMBAPrereq, "There must be at least one package with bal:PrereqPackage=\"yes\" when using the ManagedBootstrapperApplicationHost.\nThis is typically done by using the WixNetFxExtension and referencing one of the NetFxAsPrereq package groups."); |
64 | } | 64 | } |
65 | 65 | ||
66 | public static Message MultipleBAFunctions(SourceLineNumber sourceLineNumbers) | 66 | public static Message MultipleBAFunctions(SourceLineNumber sourceLineNumbers) |
diff --git a/src/ext/Bal/wixext/Symbols/BalSymbolDefinitions.cs b/src/ext/Bal/wixext/Symbols/BalSymbolDefinitions.cs index 22375508..5229f278 100644 --- a/src/ext/Bal/wixext/Symbols/BalSymbolDefinitions.cs +++ b/src/ext/Bal/wixext/Symbols/BalSymbolDefinitions.cs | |||
@@ -18,12 +18,11 @@ namespace WixToolset.Bal | |||
18 | WixStdbaOptions, | 18 | WixStdbaOptions, |
19 | WixStdbaOverridableVariable, | 19 | WixStdbaOverridableVariable, |
20 | WixMbaPrereqOptions, | 20 | WixMbaPrereqOptions, |
21 | WixBalBootstrapperApplication, | ||
21 | } | 22 | } |
22 | 23 | ||
23 | public static partial class BalSymbolDefinitions | 24 | public static partial class BalSymbolDefinitions |
24 | { | 25 | { |
25 | public static readonly Version Version = new Version("4.0.0"); | ||
26 | |||
27 | public static IntermediateSymbolDefinition ByName(string name) | 26 | public static IntermediateSymbolDefinition ByName(string name) |
28 | { | 27 | { |
29 | if (!Enum.TryParse(name, out BalSymbolDefinitionType type)) | 28 | if (!Enum.TryParse(name, out BalSymbolDefinitionType type)) |
@@ -68,6 +67,9 @@ namespace WixToolset.Bal | |||
68 | case BalSymbolDefinitionType.WixMbaPrereqOptions: | 67 | case BalSymbolDefinitionType.WixMbaPrereqOptions: |
69 | return BalSymbolDefinitions.WixMbaPrereqOptions; | 68 | return BalSymbolDefinitions.WixMbaPrereqOptions; |
70 | 69 | ||
70 | case BalSymbolDefinitionType.WixBalBootstrapperApplication: | ||
71 | return BalSymbolDefinitions.WixBalBootstrapperApplication; | ||
72 | |||
71 | default: | 73 | default: |
72 | throw new ArgumentOutOfRangeException(nameof(type)); | 74 | throw new ArgumentOutOfRangeException(nameof(type)); |
73 | } | 75 | } |
diff --git a/src/ext/Bal/wixext/Symbols/WixBalBootstrapperApplicationSymbol.cs b/src/ext/Bal/wixext/Symbols/WixBalBootstrapperApplicationSymbol.cs new file mode 100644 index 00000000..7096930d --- /dev/null +++ b/src/ext/Bal/wixext/Symbols/WixBalBootstrapperApplicationSymbol.cs | |||
@@ -0,0 +1,56 @@ | |||
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.Bal | ||
4 | { | ||
5 | using WixToolset.Data; | ||
6 | using WixToolset.Bal.Symbols; | ||
7 | |||
8 | public static partial class BalSymbolDefinitions | ||
9 | { | ||
10 | public static readonly IntermediateSymbolDefinition WixBalBootstrapperApplication = new IntermediateSymbolDefinition( | ||
11 | BalSymbolDefinitionType.WixBalBootstrapperApplication.ToString(), | ||
12 | new[] | ||
13 | { | ||
14 | new IntermediateFieldDefinition(nameof(WixBalBootstrapperApplicationSymbolFields.Type), IntermediateFieldType.Number), | ||
15 | }, | ||
16 | typeof(WixBalBootstrapperApplicationSymbol)); | ||
17 | } | ||
18 | } | ||
19 | |||
20 | namespace WixToolset.Bal.Symbols | ||
21 | { | ||
22 | using WixToolset.Data; | ||
23 | |||
24 | public enum WixBalBootstrapperApplicationType | ||
25 | { | ||
26 | Unknown, | ||
27 | Standard, | ||
28 | ManagedHost, | ||
29 | DotNetCoreHost, | ||
30 | InternalUi, | ||
31 | } | ||
32 | |||
33 | public enum WixBalBootstrapperApplicationSymbolFields | ||
34 | { | ||
35 | Type, | ||
36 | } | ||
37 | |||
38 | public class WixBalBootstrapperApplicationSymbol : IntermediateSymbol | ||
39 | { | ||
40 | public WixBalBootstrapperApplicationSymbol() : base(BalSymbolDefinitions.WixBalBootstrapperApplication, null, null) | ||
41 | { | ||
42 | } | ||
43 | |||
44 | public WixBalBootstrapperApplicationSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(BalSymbolDefinitions.WixBalBootstrapperApplication, sourceLineNumber, id) | ||
45 | { | ||
46 | } | ||
47 | |||
48 | public IntermediateField this[WixBalBootstrapperApplicationSymbolFields index] => this.Fields[(int)index]; | ||
49 | |||
50 | public WixBalBootstrapperApplicationType Type | ||
51 | { | ||
52 | get => (WixBalBootstrapperApplicationType)this.Fields[(int)WixBalBootstrapperApplicationSymbolFields.Type].AsNumber(); | ||
53 | set => this.Set((int)WixBalBootstrapperApplicationSymbolFields.Type, (int)value); | ||
54 | } | ||
55 | } | ||
56 | } | ||