diff options
| author | Rob Mensching <rob@firegiant.com> | 2024-01-11 18:26:20 -0800 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2024-03-06 18:03:38 -0800 |
| commit | 0d3d54992104288e9ee0c834d0b96e8502fd2d42 (patch) | |
| tree | 9efa49c4983cd2ba1becab64bd1f2faccac88acf /src/test/burn/TestBA | |
| parent | 2824298d9dd817a47527c920363556b54ead5d5d (diff) | |
| download | wix-0d3d54992104288e9ee0c834d0b96e8502fd2d42.tar.gz wix-0d3d54992104288e9ee0c834d0b96e8502fd2d42.tar.bz2 wix-0d3d54992104288e9ee0c834d0b96e8502fd2d42.zip | |
Move the BootstrapperApplication out of proc
Diffstat (limited to 'src/test/burn/TestBA')
| -rw-r--r-- | src/test/burn/TestBA/App.config (renamed from src/test/burn/TestBA/TestBA.BootstrapperCore.config) | 8 | ||||
| -rw-r--r-- | src/test/burn/TestBA/Program.cs | 18 | ||||
| -rw-r--r-- | src/test/burn/TestBA/TestBA.cs | 60 | ||||
| -rw-r--r-- | src/test/burn/TestBA/TestBA.csproj | 7 | ||||
| -rw-r--r-- | src/test/burn/TestBA/TestBAFactory.cs | 22 | ||||
| -rw-r--r-- | src/test/burn/TestBA/TestBA_x64.csproj | 7 |
6 files changed, 59 insertions, 63 deletions
diff --git a/src/test/burn/TestBA/TestBA.BootstrapperCore.config b/src/test/burn/TestBA/App.config index 55876a00..f9811b74 100644 --- a/src/test/burn/TestBA/TestBA.BootstrapperCore.config +++ b/src/test/burn/TestBA/App.config | |||
| @@ -3,16 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | 4 | ||
| 5 | <configuration> | 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> | 6 | <startup> |
| 12 | <supportedRuntime version="v4.0" /> | 7 | <supportedRuntime version="v4.0" /> |
| 13 | <supportedRuntime version="v2.0.50727" /> | 8 | <supportedRuntime version="v2.0.50727" /> |
| 14 | </startup> | 9 | </startup> |
| 15 | <wix.bootstrapper> | ||
| 16 | <host assemblyName="TestBA" /> | ||
| 17 | </wix.bootstrapper> | ||
| 18 | </configuration> | 10 | </configuration> |
diff --git a/src/test/burn/TestBA/Program.cs b/src/test/burn/TestBA/Program.cs new file mode 100644 index 00000000..6986a057 --- /dev/null +++ b/src/test/burn/TestBA/Program.cs | |||
| @@ -0,0 +1,18 @@ | |||
| 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.Test.BA | ||
| 4 | { | ||
| 5 | using WixToolset.Mba.Core; | ||
| 6 | |||
| 7 | internal class Program | ||
| 8 | { | ||
| 9 | private static int Main() | ||
| 10 | { | ||
| 11 | var application = new TestBA(); | ||
| 12 | |||
| 13 | ManagedBootstrapperApplication.Run(application); | ||
| 14 | |||
| 15 | return 0; | ||
| 16 | } | ||
| 17 | } | ||
| 18 | } | ||
diff --git a/src/test/burn/TestBA/TestBA.cs b/src/test/burn/TestBA/TestBA.cs index 43c1584b..8a116957 100644 --- a/src/test/burn/TestBA/TestBA.cs +++ b/src/test/burn/TestBA/TestBA.cs | |||
| @@ -42,17 +42,15 @@ namespace WixToolset.Test.BA | |||
| 42 | private int retryExecuteFilesInUse; | 42 | private int retryExecuteFilesInUse; |
| 43 | private bool rollingBack; | 43 | private bool rollingBack; |
| 44 | 44 | ||
| 45 | private IBootstrapperCommand Command { get; } | 45 | private IBootstrapperCommand Command { get; set; } |
| 46 | 46 | ||
| 47 | private IEngine Engine => this.engine; | 47 | private IEngine Engine => this.engine; |
| 48 | 48 | ||
| 49 | /// <summary> | 49 | /// <summary> |
| 50 | /// Initializes test user experience. | 50 | /// Initializes test user experience. |
| 51 | /// </summary> | 51 | /// </summary> |
| 52 | public TestBA(IEngine engine, IBootstrapperCommand bootstrapperCommand) | 52 | public TestBA() |
| 53 | : base(engine) | ||
| 54 | { | 53 | { |
| 55 | this.Command = bootstrapperCommand; | ||
| 56 | this.wait = new ManualResetEvent(false); | 54 | this.wait = new ManualResetEvent(false); |
| 57 | } | 55 | } |
| 58 | 56 | ||
| @@ -66,6 +64,12 @@ namespace WixToolset.Test.BA | |||
| 66 | /// </summary> | 64 | /// </summary> |
| 67 | private bool UpdateAvailable { get; set; } | 65 | private bool UpdateAvailable { get; set; } |
| 68 | 66 | ||
| 67 | protected override void OnCreate(CreateEventArgs args) | ||
| 68 | { | ||
| 69 | base.OnCreate(args); | ||
| 70 | this.Command = args.Command; | ||
| 71 | } | ||
| 72 | |||
| 69 | /// <summary> | 73 | /// <summary> |
| 70 | /// UI Thread entry point for TestUX. | 74 | /// UI Thread entry point for TestUX. |
| 71 | /// </summary> | 75 | /// </summary> |
| @@ -97,7 +101,7 @@ namespace WixToolset.Test.BA | |||
| 97 | { | 101 | { |
| 98 | this.updateBundlePath = arg.Substring(14); | 102 | this.updateBundlePath = arg.Substring(14); |
| 99 | FileInfo info = new FileInfo(this.updateBundlePath); | 103 | FileInfo info = new FileInfo(this.updateBundlePath); |
| 100 | this.Engine.SetUpdate(this.updateBundlePath, null, info.Length, UpdateHashType.None, null); | 104 | this.Engine.SetUpdate(this.updateBundlePath, null, info.Length, UpdateHashType.None, null, null); |
| 101 | this.UpdateAvailable = true; | 105 | this.UpdateAvailable = true; |
| 102 | this.action = LaunchAction.UpdateReplaceEmbedded; | 106 | this.action = LaunchAction.UpdateReplaceEmbedded; |
| 103 | } | 107 | } |
| @@ -124,9 +128,8 @@ namespace WixToolset.Test.BA | |||
| 124 | 128 | ||
| 125 | base.OnStartup(args); | 129 | base.OnStartup(args); |
| 126 | 130 | ||
| 127 | int redetectCount; | ||
| 128 | string redetect = this.ReadPackageAction(null, "RedetectCount"); | 131 | string redetect = this.ReadPackageAction(null, "RedetectCount"); |
| 129 | if (String.IsNullOrEmpty(redetect) || !Int32.TryParse(redetect, out redetectCount)) | 132 | if (String.IsNullOrEmpty(redetect) || !Int32.TryParse(redetect, out var redetectCount)) |
| 130 | { | 133 | { |
| 131 | redetectCount = 0; | 134 | redetectCount = 0; |
| 132 | } | 135 | } |
| @@ -163,7 +166,7 @@ namespace WixToolset.Test.BA | |||
| 163 | if (this.action == LaunchAction.Help) | 166 | if (this.action == LaunchAction.Help) |
| 164 | { | 167 | { |
| 165 | this.Log("This is a BA for automated testing"); | 168 | this.Log("This is a BA for automated testing"); |
| 166 | this.Engine.Quit(0); | 169 | this.ShutdownUiThread(0); |
| 167 | return; | 170 | return; |
| 168 | } | 171 | } |
| 169 | 172 | ||
| @@ -176,20 +179,15 @@ namespace WixToolset.Test.BA | |||
| 176 | 179 | ||
| 177 | protected override void Run() | 180 | protected override void Run() |
| 178 | { | 181 | { |
| 179 | this.dummyWindow = new Form(); | 182 | using (this.dummyWindow = new Form()) |
| 180 | this.windowHandle = this.dummyWindow.Handle; | 183 | { |
| 184 | this.windowHandle = this.dummyWindow.Handle; | ||
| 181 | 185 | ||
| 182 | this.Log("Running TestBA application"); | 186 | this.Log("Running TestBA application"); |
| 183 | this.wait.Set(); | 187 | this.wait.Set(); |
| 184 | Application.Run(); | ||
| 185 | } | ||
| 186 | 188 | ||
| 187 | private void ShutdownUiThread() | 189 | Application.Run(); |
| 188 | { | 190 | this.dummyWindow = null; |
| 189 | if (this.dummyWindow != null) | ||
| 190 | { | ||
| 191 | this.dummyWindow.Invoke(new Action(Application.ExitThread)); | ||
| 192 | this.dummyWindow.Dispose(); | ||
| 193 | } | 191 | } |
| 194 | 192 | ||
| 195 | var exitCode = this.result; | 193 | var exitCode = this.result; |
| @@ -201,6 +199,23 @@ namespace WixToolset.Test.BA | |||
| 201 | this.Engine.Quit(exitCode); | 199 | this.Engine.Quit(exitCode); |
| 202 | } | 200 | } |
| 203 | 201 | ||
| 202 | private void ShutdownUiThread(int? exitCode = null) | ||
| 203 | { | ||
| 204 | try | ||
| 205 | { | ||
| 206 | if (exitCode.HasValue) | ||
| 207 | { | ||
| 208 | this.result = exitCode.Value; | ||
| 209 | } | ||
| 210 | |||
| 211 | this.dummyWindow?.Invoke(new Action(Application.ExitThread)); | ||
| 212 | } | ||
| 213 | catch (Exception e) | ||
| 214 | { | ||
| 215 | this.Log("Failed to shutdown TestBA window, exception: {0}", e.Message); | ||
| 216 | } | ||
| 217 | } | ||
| 218 | |||
| 204 | protected override void OnDetectUpdateBegin(DetectUpdateBeginEventArgs args) | 219 | protected override void OnDetectUpdateBegin(DetectUpdateBeginEventArgs args) |
| 205 | { | 220 | { |
| 206 | this.Log("OnDetectUpdateBegin"); | 221 | this.Log("OnDetectUpdateBegin"); |
| @@ -220,7 +235,7 @@ namespace WixToolset.Test.BA | |||
| 220 | if (!this.UpdateAvailable && this.Engine.CompareVersions(e.Version, this.Version) > 0) | 235 | if (!this.UpdateAvailable && this.Engine.CompareVersions(e.Version, this.Version) > 0) |
| 221 | { | 236 | { |
| 222 | this.Log(String.Format("Selected update v{0}", e.Version)); | 237 | this.Log(String.Format("Selected update v{0}", e.Version)); |
| 223 | this.Engine.SetUpdate(null, e.UpdateLocation, e.Size, e.HashAlgorithm, e.Hash); | 238 | this.Engine.SetUpdate(null, e.UpdateLocation, e.Size, e.HashAlgorithm, e.Hash, null); |
| 224 | this.UpdateAvailable = true; | 239 | this.UpdateAvailable = true; |
| 225 | } | 240 | } |
| 226 | } | 241 | } |
| @@ -575,8 +590,7 @@ namespace WixToolset.Test.BA | |||
| 575 | // Output what the privileges are now. | 590 | // Output what the privileges are now. |
| 576 | this.Log("After elevation: WixBundleElevated = {0}", this.Engine.GetVariableNumeric("WixBundleElevated")); | 591 | this.Log("After elevation: WixBundleElevated = {0}", this.Engine.GetVariableNumeric("WixBundleElevated")); |
| 577 | 592 | ||
| 578 | this.result = args.Status; | 593 | this.ShutdownUiThread(args.Status); |
| 579 | this.ShutdownUiThread(); | ||
| 580 | } | 594 | } |
| 581 | 595 | ||
| 582 | protected override void OnUnregisterBegin(UnregisterBeginEventArgs args) | 596 | protected override void OnUnregisterBegin(UnregisterBeginEventArgs args) |
diff --git a/src/test/burn/TestBA/TestBA.csproj b/src/test/burn/TestBA/TestBA.csproj index 77f90ede..715ac5bc 100644 --- a/src/test/burn/TestBA/TestBA.csproj +++ b/src/test/burn/TestBA/TestBA.csproj | |||
| @@ -4,25 +4,22 @@ | |||
| 4 | <Project Sdk="Microsoft.NET.Sdk"> | 4 | <Project Sdk="Microsoft.NET.Sdk"> |
| 5 | <PropertyGroup> | 5 | <PropertyGroup> |
| 6 | <TargetFrameworks>net462;net6.0-windows</TargetFrameworks> | 6 | <TargetFrameworks>net462;net6.0-windows</TargetFrameworks> |
| 7 | <OutputType>WinExe</OutputType> | ||
| 7 | <AssemblyName>TestBA</AssemblyName> | 8 | <AssemblyName>TestBA</AssemblyName> |
| 8 | <RootNamespace>WixToolset.Test.BA</RootNamespace> | 9 | <RootNamespace>WixToolset.Test.BA</RootNamespace> |
| 9 | <DebugType>embedded</DebugType> | 10 | <DebugType>embedded</DebugType> |
| 10 | <RuntimeIdentifier>win-x86</RuntimeIdentifier> | 11 | <RuntimeIdentifier>win-x86</RuntimeIdentifier> |
| 11 | <EnableDynamicLoading>true</EnableDynamicLoading> | 12 | <EnableDynamicLoading>true</EnableDynamicLoading> |
| 12 | <UseWindowsForms>true</UseWindowsForms> | 13 | <UseWindowsForms>true</UseWindowsForms> |
| 14 | <SelfContained>false</SelfContained> | ||
| 13 | <RollForward>Major</RollForward> | 15 | <RollForward>Major</RollForward> |
| 14 | </PropertyGroup> | 16 | </PropertyGroup> |
| 15 | 17 | ||
| 16 | <ItemGroup Condition=" '$(TargetFramework)'=='net462' "> | 18 | <ItemGroup Condition=" '$(TargetFramework)'=='net462' "> |
| 17 | <Content Include="TestBA.BootstrapperCore.config" CopyToOutputDirectory="PreserveNewest" /> | ||
| 18 | <Reference Include="System.Windows.Forms" /> | 19 | <Reference Include="System.Windows.Forms" /> |
| 19 | </ItemGroup> | 20 | </ItemGroup> |
| 20 | 21 | ||
| 21 | <ItemGroup> | 22 | <ItemGroup> |
| 22 | <PackageReference Include="WixToolset.Mba.Core" /> | 23 | <PackageReference Include="WixToolset.Mba.Core" /> |
| 23 | </ItemGroup> | 24 | </ItemGroup> |
| 24 | |||
| 25 | <ItemGroup Condition=" '$(TargetFrameworkIdentifier)'!='.NETFramework' "> | ||
| 26 | <PackageReference Include="WixToolset.Dnc.HostGenerator" /> | ||
| 27 | </ItemGroup> | ||
| 28 | </Project> | 25 | </Project> |
diff --git a/src/test/burn/TestBA/TestBAFactory.cs b/src/test/burn/TestBA/TestBAFactory.cs deleted file mode 100644 index ba1de367..00000000 --- a/src/test/burn/TestBA/TestBAFactory.cs +++ /dev/null | |||
| @@ -1,22 +0,0 @@ | |||
| 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 | [assembly: WixToolset.Mba.Core.BootstrapperApplicationFactory(typeof(WixToolset.Test.BA.TestBAFactory))] | ||
| 4 | namespace WixToolset.Test.BA | ||
| 5 | { | ||
| 6 | using WixToolset.Mba.Core; | ||
| 7 | |||
| 8 | public class TestBAFactory : BaseBootstrapperApplicationFactory | ||
| 9 | { | ||
| 10 | private static int loadCount = 0; | ||
| 11 | |||
| 12 | protected override IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand) | ||
| 13 | { | ||
| 14 | if (loadCount > 0) | ||
| 15 | { | ||
| 16 | engine.Log(LogLevel.Standard, $"Reloaded {loadCount} time(s)"); | ||
| 17 | } | ||
| 18 | ++loadCount; | ||
| 19 | return new TestBA(engine, bootstrapperCommand); | ||
| 20 | } | ||
| 21 | } | ||
| 22 | } | ||
diff --git a/src/test/burn/TestBA/TestBA_x64.csproj b/src/test/burn/TestBA/TestBA_x64.csproj index 0669eee1..1f8659a0 100644 --- a/src/test/burn/TestBA/TestBA_x64.csproj +++ b/src/test/burn/TestBA/TestBA_x64.csproj | |||
| @@ -4,25 +4,22 @@ | |||
| 4 | <Project Sdk="Microsoft.NET.Sdk"> | 4 | <Project Sdk="Microsoft.NET.Sdk"> |
| 5 | <PropertyGroup> | 5 | <PropertyGroup> |
| 6 | <TargetFrameworks>net462;net6.0-windows</TargetFrameworks> | 6 | <TargetFrameworks>net462;net6.0-windows</TargetFrameworks> |
| 7 | <OutputType>WinExe</OutputType> | ||
| 7 | <AssemblyName>TestBA</AssemblyName> | 8 | <AssemblyName>TestBA</AssemblyName> |
| 8 | <RootNamespace>WixToolset.Test.BA</RootNamespace> | 9 | <RootNamespace>WixToolset.Test.BA</RootNamespace> |
| 9 | <DebugType>embedded</DebugType> | 10 | <DebugType>embedded</DebugType> |
| 10 | <RuntimeIdentifier>win-x64</RuntimeIdentifier> | 11 | <RuntimeIdentifier>win-x64</RuntimeIdentifier> |
| 11 | <EnableDynamicLoading>true</EnableDynamicLoading> | 12 | <EnableDynamicLoading>true</EnableDynamicLoading> |
| 12 | <UseWindowsForms>true</UseWindowsForms> | 13 | <UseWindowsForms>true</UseWindowsForms> |
| 14 | <SelfContained>false</SelfContained> | ||
| 13 | <RollForward>Major</RollForward> | 15 | <RollForward>Major</RollForward> |
| 14 | </PropertyGroup> | 16 | </PropertyGroup> |
| 15 | 17 | ||
| 16 | <ItemGroup Condition=" '$(TargetFramework)'=='net462' "> | 18 | <ItemGroup Condition=" '$(TargetFramework)'=='net462' "> |
| 17 | <Content Include="TestBA.BootstrapperCore.config" CopyToOutputDirectory="PreserveNewest" /> | ||
| 18 | <Reference Include="System.Windows.Forms" /> | 19 | <Reference Include="System.Windows.Forms" /> |
| 19 | </ItemGroup> | 20 | </ItemGroup> |
| 20 | 21 | ||
| 21 | <ItemGroup> | 22 | <ItemGroup> |
| 22 | <PackageReference Include="WixToolset.Mba.Core" /> | 23 | <PackageReference Include="WixToolset.Mba.Core" /> |
| 23 | </ItemGroup> | 24 | </ItemGroup> |
| 24 | |||
| 25 | <ItemGroup Condition=" '$(TargetFrameworkIdentifier)'!='.NETFramework' "> | ||
| 26 | <PackageReference Include="WixToolset.Dnc.HostGenerator" /> | ||
| 27 | </ItemGroup> | ||
| 28 | </Project> | 25 | </Project> |
