@joebigelow / wix-1 / commits / 05edba00

Update BalBurnBackendExtension to use BundleFinalize.

Sean Hall committed Apr 23, 2020 at 12:11 UTC 05edba00dc08b74a6d9b32b4e56f4da6ef90c638
5 files changed +48 -14
src/test/WixToolsetTest.Bal/BalExtensionFixture.cs
+28
@@ -34,5 +34,33 @@ namespace WixToolsetTest.Bal
34 Assert.True(File.Exists(bundleFile));
35 }
36 }
37 +
38 + [Fact]
39 + public void CantBuildUsingMBAWithNoPrereqs()
40 + {
41 + using (var fs = new DisposableFileSystem())
42 + {
43 + var baseFolder = fs.GetFolder();
44 + var bundleFile = Path.Combine(baseFolder, "bin", "test.exe");
45 + var bundleSourceFolder = TestData.Get(@"TestData\MBA");
46 + var intermediateFolder = Path.Combine(baseFolder, "obj");
47 +
48 + var compileResult = WixRunner.Execute(new[]
49 + {
50 + "build",
51 + Path.Combine(bundleSourceFolder, "Bundle.wxs"),
52 + "-ext", TestData.Get(@"WixToolset.Bal.wixext.dll"),
53 + "-ext", TestData.Get(@"WixToolset.NetFx.wixext.dll"),
54 + "-intermediateFolder", intermediateFolder,
55 + "-burnStub", TestData.Get(@"runtimes\win-x86\native\burn.x86.exe"),
56 + "-o", bundleFile,
57 + });
58 + Assert.Equal(6802, compileResult.ExitCode);
59 + Assert.Equal("There must be at least one PrereqPackage when using the ManagedBootstrapperApplicationHost.\nThis is typically done by using the WixNetFxExtension and referencing one of the NetFxAsPrereq package groups.", compileResult.Messages[0].ToString());
60 +
61 + Assert.False(File.Exists(bundleFile));
62 + Assert.False(File.Exists(Path.Combine(intermediateFolder, "test.exe")));
63 + }
64 + }
65 }
66 }
src/test/WixToolsetTest.Bal/TestData/MBA/Bundle.wxs new
+10
@@ -0,0 +1,10 @@
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 + <BootstrapperApplicationRef Id="ManagedBootstrapperApplicationHost" />
6 + <Chain>
7 + <PackageGroupRef Id="NetFx462Redist" />
8 + </Chain>
9 + </Bundle>
10 +</Wix>
src/test/WixToolsetTest.Bal/TestData/WixStdBa/Bundle.wxs
+1 -4
@@ -6,10 +6,7 @@
6 <bal:WixStandardBootstrapperApplication LicenseUrl="http://wixtoolset.org/about/license/" />
7 </BootstrapperApplicationRef>
8 <Chain>
9 - <!-- TODO: Replace ExePackage below with this -->
10 - <!-- <PackageGroupRef Id="NetFx462RedistAsPrereq" /> -->
11 - <!-- TODO: Remove explicit PerMachine -->
12 - <ExePackage SourceFile="runtimes\win-x86\native\wixnative.x86.exe" PerMachine="no" />
9 + <ExePackage SourceFile="runtimes\win-x86\native\wixnative.x86.exe" />
10 </Chain>
11 </Bundle>
12 </Wix>
src/test/WixToolsetTest.Bal/WixToolsetTest.Bal.csproj
+6
@@ -12,9 +12,14 @@
12 </PropertyGroup>
13
14 <ItemGroup>
15 + <Content Include="TestData\MBA\Bundle.wxs" CopyToOutputDirectory="PreserveNewest" />
16 <Content Include="TestData\WixStdBa\Bundle.wxs" CopyToOutputDirectory="PreserveNewest" />
17 </ItemGroup>
18
19 + <Target Name="CopyExtensions" AfterTargets="Build">
20 + <Copy DestinationFolder="$(OutputPath)" SourceFiles="@(WixExtension)" />
21 + </Target>
22 +
23 <ItemGroup>
24 <ProjectReference Include="..\..\wixext\WixToolset.Bal.wixext.csproj" />
25 </ItemGroup>
@@ -25,6 +30,7 @@
30 <PackageReference Include="WixToolset.Core.Burn" Version="4.0.*" />
31 <PackageReference Include="WixToolset.Core.WindowsInstaller" Version="4.0.*" />
32 <PackageReference Include="WixToolset.Core.TestPackage" Version="4.0.*" />
33 + <PackageReference Include="WixToolset.NetFx.wixext" Version="4.0.*" />
34 </ItemGroup>
35
36 <ItemGroup>
src/wixext/BalBurnBackendExtension.cs
+3 -10
@@ -9,21 +9,14 @@ namespace WixToolset.Bal
9 using WixToolset.Data.Burn;
10 using WixToolset.Data.Tuples;
11 using WixToolset.Extensibility;
12 - using WixToolset.Extensibility.Data;
12
13 public class BalBurnBackendExtension : BaseBurnBackendExtension
14 {
16 - public override void PostBackendBind(IBindResult result)
15 + public override void BundleFinalize()
16 {
18 - base.PostBackendBind(result);
17 + base.BundleFinalize();
18
20 - if (result.Wixout == null)
21 - {
22 - this.Messaging.Write(new Message(null, MessageLevel.Warning, 1, "BurnBackend didn't provide Wixout so skipping BalExtension PostBind verification."));
23 - return;
24 - }
25 -
26 - var intermediate = Intermediate.Load(result.Wixout);
19 + var intermediate = this.Context.IntermediateRepresentation;
20 var section = intermediate.Sections.Single();
21
22 var baTuple = section.Tuples.OfType<WixBootstrapperApplicationTuple>().SingleOrDefault();