@joebigelow / wix-1 / commits / ecbaffc0

Write an error when the .NET Core BA is missing the BAFactoryAssembly.

7166

Sean Hall committed Jan 15, 2023 at 20:59 UTC ecbaffc08239e061a7dbaa92ff3c72acd53a0bae
4 files changed +52 -2
src/ext/Bal/test/WixToolsetTest.Bal/BalExtensionFixture.cs
+29
@@ -184,6 +184,35 @@ namespace WixToolsetTest.Bal
184 }
185 }
186
187 + [Fact]
188 + public void CannotBuildUsingDncbaMissingBAFactoryPayload()
189 + {
190 + using (var fs = new DisposableFileSystem())
191 + {
192 + var baseFolder = fs.GetFolder();
193 + var bundleFile = Path.Combine(baseFolder, "bin", "test.exe");
194 + var bundleSourceFolder = TestData.Get(@"TestData\Dncba");
195 + var intermediateFolder = Path.Combine(baseFolder, "obj");
196 +
197 + var compileResult = WixRunner.Execute(new[]
198 + {
199 + "build",
200 + Path.Combine(bundleSourceFolder, "Bundle.wxs"),
201 + "-ext", TestData.Get(@"WixToolset.Bal.wixext.dll"),
202 + "-intermediateFolder", intermediateFolder,
203 + "-o", bundleFile,
204 + });
205 + WixAssert.CompareLineByLine(new[]
206 + {
207 + "The BA's entry point DLL must have bal:BAFactoryAssembly=\"yes\" when using the DotNetCoreBootstrapperApplicationHost.",
208 + }, compileResult.Messages.Select(x => x.ToString()).ToArray());
209 + Assert.Equal(6818, compileResult.ExitCode);
210 +
211 + Assert.False(File.Exists(bundleFile));
212 + Assert.False(File.Exists(Path.Combine(intermediateFolder, "test.exe")));
213 + }
214 + }
215 +
216 [Fact]
217 public void CannotBuildUsingOverridableWrongCase()
218 {
src/ext/Bal/test/WixToolsetTest.Bal/TestData/Dncba/Bundle.wxs new
+13
@@ -0,0 +1,13 @@
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
3 + xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal">
4 + <Bundle Name="WixStdBa" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="75D5D534-E177-4689-AAE9-CAC1C39002C2">
5 + <BootstrapperApplication>
6 + <bal:WixDotNetCoreBootstrapperApplicationHost SelfContainedDeployment="yes" />
7 + <Payload SourceFile="runtimes\win-x86\native\wixnative.exe" />
8 + </BootstrapperApplication>
9 + <Chain>
10 + <ExePackage Permanent="yes" DetectCondition="none" SourceFile="runtimes\win-x86\native\wixnative.exe" />
11 + </Chain>
12 + </Bundle>
13 +</Wix>
src/ext/Bal/wixext/BalBurnBackendExtension.cs
+4 -2
@@ -121,7 +121,7 @@ namespace WixToolset.Bal
121
122 if (isDNC)
123 {
124 - this.FinalizeBAFactorySymbol(section);
124 + this.FinalizeBAFactorySymbol(section, baSymbol);
125 }
126
127 if (isIuiBA || isStdBA || isMBA || isDNC)
@@ -135,11 +135,12 @@ namespace WixToolset.Bal
135 }
136 }
137
138 - private void FinalizeBAFactorySymbol(IntermediateSection section)
138 + private void FinalizeBAFactorySymbol(IntermediateSection section, WixBootstrapperApplicationDllSymbol baSymbol)
139 {
140 var factorySymbol = section.Symbols.OfType<WixBalBAFactoryAssemblySymbol>().SingleOrDefault();
141 if (null == factorySymbol)
142 {
143 + this.Messaging.Write(BalErrors.MissingDNCBAFactoryAssembly(baSymbol.SourceLineNumbers));
144 return;
145 }
146
@@ -148,6 +149,7 @@ namespace WixToolset.Bal
149 .SingleOrDefault();
150 if (null == factoryPayloadSymbol)
151 {
152 + this.Messaging.Write(BalErrors.MissingDNCBAFactoryAssembly(factorySymbol.SourceLineNumbers));
153 return;
154 }
155
src/ext/Bal/wixext/BalErrors.cs
+6
@@ -43,6 +43,11 @@ namespace WixToolset.Bal
43 return Message(sourceLineNumbers, Ids.IuibaPrimaryPackageEnableFeatureSelection, "When using WixInternalUIBootstrapperApplication, primary packages must not have feature selection enabled because it interferes with the user selecting feature through the MSI UI.");
44 }
45
46 + public static Message MissingDNCBAFactoryAssembly(SourceLineNumber sourceLineNumbers)
47 + {
48 + return Message(sourceLineNumbers, Ids.MissingDNCBAFactoryAssembly, "The BA's entry point DLL must have bal:BAFactoryAssembly=\"yes\" when using the DotNetCoreBootstrapperApplicationHost.");
49 + }
50 +
51 public static Message MissingDNCPrereq()
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\".");
@@ -116,6 +121,7 @@ namespace WixToolset.Bal
121 IuibaPrimaryPackageEnableFeatureSelection = 6815,
122 OverridableVariableCollision = 6816,
123 OverridableVariableCollision2 = 6817,
124 + MissingDNCBAFactoryAssembly = 6818,
125 }
126 }
127 }