@joebigelow / wix / commits / 73dc2706

Add tests for wrong managed BA configuration.

Test out the .NET Core test BA as well.

Sean Hall committed Jan 1, 2021 at 19:11 UTC 73dc2706d9f151554356aaf3e69bfad5b46a21e9
18 files changed +267 -12
src/TestData/MsiTransaction/BundleBv1/BundleB.wxi
-1
@@ -11,7 +11,6 @@
11 <Variable Name="TestGroupName" Value="$(var.TestGroupName)" />
12
13 <Chain>
14 - <PackageGroupRef Id="TestBA" />
14 <PackageGroupRef Id="BundlePackages" />
15 </Chain>
16 </Bundle>
src/TestData/MsiTransaction/BundleBv1/BundleBv1.wxs
+1
@@ -5,6 +5,7 @@
5 <?include BundleB.wxi ?>
6 <Fragment>
7 <PackageGroup Id="BundlePackages">
8 + <PackageGroupRef Id="TestBA" />
9 <MsiPackage Id="PackageB" SourceFile="$(var.PackageBv1.TargetPath)" />
10 </PackageGroup>
11 </Fragment>
src/TestData/MsiTransaction/BundleBv2/BundleBv2.wxs
+1
@@ -5,6 +5,7 @@
5 <?include ..\BundleBv1\BundleB.wxi ?>
6 <Fragment>
7 <PackageGroup Id="BundlePackages">
8 + <PackageGroupRef Id="TestBAdnc" />
9 <MsiPackage Id="PackageA" SourceFile="$(var.PackageA.TargetPath)" />
10 <RollbackBoundary Transaction="yes" />
11 <MsiPackage Id="PackageB" SourceFile="$(var.PackageBv2.TargetPath)" />
src/TestData/PrereqBa/BundleA/BundleA.wixproj new
+16
@@ -0,0 +1,16 @@
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 +<Project Sdk="WixToolset.Sdk">
3 + <PropertyGroup>
4 + <OutputType>Bundle</OutputType>
5 + </PropertyGroup>
6 + <ItemGroup>
7 + <BindInputPaths Include="$(OutputPath)..\net5.0-windows\win-x86" BindName="dnc5x86" />
8 + </ItemGroup>
9 + <ItemGroup>
10 + <ProjectReference Include="..\PackageA\PackageA.wixproj" />
11 + <ProjectReference Include="..\PackageF\PackageF.wixproj" />
12 + </ItemGroup>
13 + <ItemGroup>
14 + <PackageReference Include="WixToolset.Bal.wixext" Version="4.0.77" />
15 + </ItemGroup>
16 +</Project>
\ No newline at end of file
src/TestData/PrereqBa/BundleA/BundleA.wxi new
+17
@@ -0,0 +1,17 @@
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 +<?ifndef Version?>
4 +<?define Version = 1.0.0.0?>
5 +<?endif?>
6 +
7 +<Include xmlns="http://wixtoolset.org/schemas/v4/wxs">
8 + <Bundle Name="~$(var.TestGroupName) - Bundle A" Version="$(var.Version)" UpgradeCode="{A4456636-916A-43A0-87BF-A897C2717A00}" Compressed="yes">
9 + <Log Prefix="~$(var.TestGroupName)_BundleA" />
10 +
11 + <Variable Name="TestGroupName" Value="$(var.TestGroupName)" />
12 +
13 + <Chain>
14 + <PackageGroupRef Id="BundlePackages" />
15 + </Chain>
16 + </Bundle>
17 +</Include>
src/TestData/PrereqBa/BundleA/BundleA.wxs new
+21
@@ -0,0 +1,21 @@
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 +
4 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal">
5 + <?include BundleA.wxi ?>
6 + <Fragment>
7 + <BootstrapperApplication>
8 + <Payload SourceFile="!(bindpath.dnc5x86)\TestBA.deps.json" />
9 + <Payload SourceFile="!(bindpath.dnc5x86)\TestBA.dll" bal:BAFactoryAssembly="yes" />
10 + <Payload Name="TestBA.runtimeconfig.json" SourceFile="bad.runtimeconfig.json" />
11 + <Payload SourceFile="!(bindpath.dnc5x86)\mbanative.dll" />
12 + <Payload SourceFile="!(bindpath.dnc5x86)\WixToolset.Mba.Core.dll" />
13 + <bal:WixDotNetCoreBootstrapperApplicationHost />
14 + </BootstrapperApplication>
15 +
16 + <PackageGroup Id="BundlePackages">
17 + <MsiPackage Id="PackageA" SourceFile="$(var.PackageA.TargetPath)" bal:PrereqPackage="yes" Permanent="yes" />
18 + <MsiPackage Id="PackageF" SourceFile="$(var.PackageF.TargetPath)" />
19 + </PackageGroup>
20 + </Fragment>
21 +</Wix>
src/TestData/PrereqBa/BundleA/bad.runtimeconfig.json new
+10
@@ -0,0 +1,10 @@
1 +{
2 + "runtimeOptions": {
3 + "tfm": "net5.5",
4 + "rollForward": "Disable",
5 + "framework": {
6 + "name": "Microsoft.WindowsDesktop.App",
7 + "version": "5.5.0"
8 + }
9 + }
10 +}
\ No newline at end of file
src/TestData/PrereqBa/BundleB/BundleB.wixproj new
+16
@@ -0,0 +1,16 @@
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 +<Project Sdk="WixToolset.Sdk">
3 + <PropertyGroup>
4 + <OutputType>Bundle</OutputType>
5 + </PropertyGroup>
6 + <ItemGroup>
7 + <BindInputPaths Include="$(OutputPath)..\net35\win-x86" BindName="net2x86" />
8 + </ItemGroup>
9 + <ItemGroup>
10 + <ProjectReference Include="..\PackageB\PackageB.wixproj" />
11 + <ProjectReference Include="..\PackageF\PackageF.wixproj" />
12 + </ItemGroup>
13 + <ItemGroup>
14 + <PackageReference Include="WixToolset.Bal.wixext" Version="4.0.77" />
15 + </ItemGroup>
16 +</Project>
\ No newline at end of file
src/TestData/PrereqBa/BundleB/BundleB.wxi new
+17
@@ -0,0 +1,17 @@
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 +<?ifndef Version?>
4 +<?define Version = 1.0.0.0?>
5 +<?endif?>
6 +
7 +<Include xmlns="http://wixtoolset.org/schemas/v4/wxs">
8 + <Bundle Name="~$(var.TestGroupName) - Bundle B" Version="$(var.Version)" UpgradeCode="{157A1FBA-3825-4AAA-B13D-F45435A79D64}" Compressed="yes">
9 + <Log Prefix="~$(var.TestGroupName)_BundleB" />
10 +
11 + <Variable Name="TestGroupName" Value="$(var.TestGroupName)" />
12 +
13 + <Chain>
14 + <PackageGroupRef Id="BundlePackages" />
15 + </Chain>
16 + </Bundle>
17 +</Include>
src/TestData/PrereqBa/BundleB/BundleB.wxs new
+20
@@ -0,0 +1,20 @@
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 +
4 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal">
5 + <?include BundleB.wxi ?>
6 + <Fragment>
7 + <BootstrapperApplication>
8 + <Payload Name="WixToolset.Mba.Host.config" SourceFile="bad.config" />
9 + <Payload SourceFile="!(bindpath.net2x86)\TestBA.dll" />
10 + <Payload SourceFile="!(bindpath.net2x86)\mbanative.dll" />
11 + <Payload SourceFile="!(bindpath.net2x86)\WixToolset.Mba.Core.dll" />
12 + <bal:WixManagedBootstrapperApplicationHost />
13 + </BootstrapperApplication>
14 +
15 + <PackageGroup Id="BundlePackages">
16 + <MsiPackage Id="PackageB" SourceFile="$(var.PackageB.TargetPath)" bal:PrereqPackage="yes" Permanent="yes" />
17 + <MsiPackage Id="PackageF" SourceFile="$(var.PackageF.TargetPath)" />
18 + </PackageGroup>
19 + </Fragment>
20 +</Wix>
src/TestData/PrereqBa/BundleB/bad.config new
+17
@@ -0,0 +1,17 @@
1 +<?xml version="1.0" encoding="utf-8" ?>
2 +<!-- 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. -->
3 +
4 +
5 +<configuration>
6 + <configSections>
7 + <sectionGroup name="wix.bootstrapper" type="WixToolset.Mba.Host.BootstrapperSectionGroup, WixToolset.Mba.Host">
8 + <section name="host" type="WixToolset.Mba.Host.HostSection, WixToolset.Mba.Host" />
9 + </sectionGroup>
10 + </configSections>
11 + <startup>
12 + <supportedRuntime version="v4.0" sku=".NETFramework,Version=v5.8" />
13 + </startup>
14 + <wix.bootstrapper>
15 + <host assemblyName="TestBA" />
16 + </wix.bootstrapper>
17 +</configuration>
src/TestData/PrereqBa/PackageA/PackageA.wixproj new
+9
@@ -0,0 +1,9 @@
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 +<Project Sdk="WixToolset.Sdk">
3 + <PropertyGroup>
4 + <UpgradeCode>{A13BFF68-61DF-4015-9AD1-03854B5E0212}</UpgradeCode>
5 + </PropertyGroup>
6 + <ItemGroup>
7 + <Compile Include="..\..\Templates\Package.wxs" Link="Package.wxs" />
8 + </ItemGroup>
9 +</Project>
\ No newline at end of file
src/TestData/PrereqBa/PackageB/PackageB.wixproj new
+9
@@ -0,0 +1,9 @@
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 +<Project Sdk="WixToolset.Sdk">
3 + <PropertyGroup>
4 + <UpgradeCode>{3DD4621A-F7AB-4548-89A8-6DCB0A9BC954}</UpgradeCode>
5 + </PropertyGroup>
6 + <ItemGroup>
7 + <Compile Include="..\..\Templates\Package.wxs" Link="Package.wxs" />
8 + </ItemGroup>
9 +</Project>
\ No newline at end of file
src/TestData/PrereqBa/PackageF/PackageF.wixproj new
+12
@@ -0,0 +1,12 @@
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 +<Project Sdk="WixToolset.Sdk">
3 + <PropertyGroup>
4 + <UpgradeCode>{7DEEE928-CD7F-49AD-8000-2ED6339D8A78}</UpgradeCode>
5 + </PropertyGroup>
6 + <ItemGroup>
7 + <Compile Include="..\..\Templates\PackageFail.wxs" Link="PackageFail.wxs" />
8 + </ItemGroup>
9 + <ItemGroup>
10 + <PackageReference Include="WixToolset.Util.wixext" Version="4.0.66" />
11 + </ItemGroup>
12 +</Project>
\ No newline at end of file
src/TestData/TestBA/TestBAWixlib/TestBA.wxs
+18 -4
@@ -2,10 +2,24 @@
2 <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal">
3 <Fragment>
4 <BootstrapperApplication>
5 - <Payload Name="WixToolset.Mba.Host.config" SourceFile="!(bindpath.x86)\TestBA.BootstrapperCore.config" />
6 - <Payload SourceFile="!(bindpath.x86)\TestBA.dll" />
7 - <Payload SourceFile="!(bindpath.x86)\mbanative.dll" />
8 - <Payload SourceFile="!(bindpath.x86)\WixToolset.Mba.Core.dll" />
5 + <Payload SourceFile="!(bindpath.dnc5x86)\TestBA.deps.json" />
6 + <Payload SourceFile="!(bindpath.dnc5x86)\TestBA.dll" bal:BAFactoryAssembly="yes" />
7 + <Payload SourceFile="!(bindpath.dnc5x86)\TestBA.runtimeconfig.json" />
8 + <Payload SourceFile="!(bindpath.dnc5x86)\mbanative.dll" />
9 + <Payload SourceFile="!(bindpath.dnc5x86)\WixToolset.Mba.Core.dll" />
10 + <bal:WixDotNetCoreBootstrapperApplicationHost />
11 + </BootstrapperApplication>
12 +
13 + <PackageGroup Id="TestBAdnc">
14 + <PackageGroupRef Id="NetFx48WebAsPrereq" /> <!-- Yes, this is wrong but we don't have .NET 5 packages yet -->
15 + </PackageGroup>
16 + </Fragment>
17 + <Fragment>
18 + <BootstrapperApplication>
19 + <Payload Name="WixToolset.Mba.Host.config" SourceFile="!(bindpath.net2x86)\TestBA.BootstrapperCore.config" />
20 + <Payload SourceFile="!(bindpath.net2x86)\TestBA.dll" />
21 + <Payload SourceFile="!(bindpath.net2x86)\mbanative.dll" />
22 + <Payload SourceFile="!(bindpath.net2x86)\WixToolset.Mba.Core.dll" />
23 <bal:WixManagedBootstrapperApplicationHost />
24 </BootstrapperApplication>
25
src/TestData/TestBA/TestBAWixlib/testbawixlib.wixproj
+2 -1
@@ -6,7 +6,8 @@
6 <Cultures>en-us</Cultures>
7 </PropertyGroup>
8 <ItemGroup>
9 - <BindInputPaths Include="$(OutputPath)..\net35\win-x86" BindName="x86" />
9 + <BindInputPaths Include="$(OutputPath)..\net35\win-x86" BindName="net2x86" />
10 + <BindInputPaths Include="$(OutputPath)..\net5.0-windows\win-x86" BindName="dnc5x86" />
11 </ItemGroup>
12 <ItemGroup>
13 <ProjectReference Include="..\..\..\Utilities\TestBA\TestBA.csproj" />
src/Utilities/TestBA/TestBA.csproj
+5 -6
@@ -3,22 +3,21 @@
3
4 <Project Sdk="Microsoft.NET.Sdk">
5 <PropertyGroup>
6 - <TargetFramework>net35</TargetFramework>
6 + <TargetFrameworks>net35;net5.0-windows</TargetFrameworks>
7 <AssemblyName>TestBA</AssemblyName>
8 <RootNamespace>WixToolset.Test.BA</RootNamespace>
9 <DebugType>embedded</DebugType>
10 <RuntimeIdentifier>win-x86</RuntimeIdentifier>
11 + <EnableDynamicLoading>true</EnableDynamicLoading>
12 + <UseWindowsForms>true</UseWindowsForms>
13 </PropertyGroup>
14
13 - <ItemGroup>
15 + <ItemGroup Condition=" '$(TargetFramework)'=='net35' ">
16 <Content Include="TestBA.BootstrapperCore.config" CopyToOutputDirectory="PreserveNewest" />
17 + <Reference Include="System.Windows.Forms" />
18 </ItemGroup>
19
20 <ItemGroup>
21 <PackageReference Include="WixToolset.Mba.Core" Version="4.0.45" />
22 </ItemGroup>
20 -
21 - <ItemGroup>
22 - <Reference Include="System.Windows.Forms" />
23 - </ItemGroup>
23 </Project>
\ No newline at end of file
src/WixToolsetTest.BurnE2E/PrereqBaTests.cs new
+76
@@ -0,0 +1,76 @@
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 WixToolsetTest.BurnE2E
4 +{
5 + using System;
6 + using System.IO;
7 + using Xunit;
8 + using Xunit.Abstractions;
9 +
10 + public class PrereqBaTests : BurnE2ETests
11 + {
12 + public PrereqBaTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper, "PrereqBa") { }
13 +
14 + /// <summary>
15 + /// This bundle purposely provides a .runtimeconfig.json file that requires a version of .NET Core that doesn't exist,
16 + /// with an MSI package to represent the prerequisite package.
17 + /// This verifies that:
18 + /// The preqba doesn't infinitely reload itself after failing to load the managed BA.
19 + /// The engine automatically uninstalls the bundle since only permanent packages were installed.
20 + /// </summary>
21 + [Fact]
22 + public void DncPreqBaDetectsInfiniteLoop()
23 + {
24 + var packageA = this.CreatePackageInstaller("PackageA");
25 + this.CreatePackageInstaller("PackageF");
26 +
27 + var bundleA = this.CreateBundleInstaller("BundleA");
28 +
29 + var packageASourceCodeInstalled = packageA.GetInstalledFilePath("Package.wxs");
30 +
31 + // Source file should *not* be installed
32 + Assert.False(File.Exists(packageASourceCodeInstalled), $"Package A payload should not be there on test start: {packageASourceCodeInstalled}");
33 +
34 + bundleA.Install();
35 +
36 + // Part of the test is Install actually completing.
37 +
38 + // Source file should be installed
39 + Assert.True(File.Exists(packageASourceCodeInstalled), String.Concat("Should have found Package A payload installed at: ", packageASourceCodeInstalled));
40 +
41 + // No non-permanent packages should have ended up installed or cached so it should have unregistered.
42 + bundleA.VerifyUnregisteredAndRemovedFromPackageCache();
43 + }
44 +
45 + /// <summary>
46 + /// This bundle purposely provides a WixToolset.Mba.Host.config file that requires a version of .NET Framework that doesn't exist,
47 + /// with an MSI package to represent the prerequisite package.
48 + /// This verifies that:
49 + /// The preqba doesn't infinitely reload itself after failing to load the managed BA.
50 + /// The engine automatically uninstalls the bundle since only permanent packages were installed.
51 + /// </summary>
52 + [Fact]
53 + public void MbaPreqBaDetectsInfiniteLoop()
54 + {
55 + var packageB = this.CreatePackageInstaller("PackageB");
56 + this.CreatePackageInstaller("PackageF");
57 +
58 + var bundleB = this.CreateBundleInstaller("BundleB");
59 +
60 + var packageBSourceCodeInstalled = packageB.GetInstalledFilePath("Package.wxs");
61 +
62 + // Source file should *not* be installed
63 + Assert.False(File.Exists(packageBSourceCodeInstalled), $"Package B payload should not be there on test start: {packageBSourceCodeInstalled}");
64 +
65 + bundleB.Install();
66 +
67 + // Part of the test is Install actually completing.
68 +
69 + // Source file should be installed
70 + Assert.True(File.Exists(packageBSourceCodeInstalled), String.Concat("Should have found Package B payload installed at: ", packageBSourceCodeInstalled));
71 +
72 + // No non-permanent packages should have ended up installed or cached so it should have unregistered.
73 + bundleB.VerifyUnregisteredAndRemovedFromPackageCache();
74 + }
75 + }
76 +}