From ba7bab476501c16e437b0aee71c1be02c3dda176 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Mon, 3 May 2021 15:55:48 -0700 Subject: Move Bal.wixext into ext --- src/ext/Bal/test/examples/Directory.Build.props | 6 + src/ext/Bal/test/examples/Directory.Build.targets | 6 + .../EarliestCoreBundleFDD.wixproj | 2 + .../FrameworkDependentBundle.wxs | 16 ++ .../EarliestCoreBundleSCD.wixproj | 10 + .../EarliestCoreBundleSCD/SelfContainedBundle.wxs | 11 + .../test/examples/EarliestCoreBundleSCD/ba.xslt | 20 ++ .../EarliestCoreBundleTrimmedSCD.wixproj | 10 + .../TrimmedSelfContainedBundle.wxs | 11 + .../examples/EarliestCoreBundleTrimmedSCD/ba.xslt | 20 ++ .../examples/EarliestCoreMBA/EarliestCoreBA.cs | 34 +++ .../EarliestCoreMBA/EarliestCoreBAFactory.cs | 22 ++ .../EarliestCoreMBA/Example.EarliestCoreMBA.csproj | 18 ++ .../test/examples/FullFramework2Bundle/Bundle.wxs | 14 ++ .../FullFramework2Bundle.wixproj | 2 + .../Example.FullFramework2MBA.csproj | 20 ++ .../examples/FullFramework2MBA/FullFramework2BA.cs | 34 +++ .../FullFramework2MBA/FullFramework2BAFactory.cs | 22 ++ .../FullFramework2MBA/WixToolset.Mba.Host.config | 20 ++ .../test/examples/FullFramework4Bundle/Bundle.wxs | 14 ++ .../FullFramework4Bundle.wixproj | 2 + .../Example.FullFramework4MBA.csproj | 19 ++ .../examples/FullFramework4MBA/FullFramework4BA.cs | 34 +++ .../FullFramework4MBA/FullFramework4BAFactory.cs | 22 ++ .../FullFramework4MBA/WixToolset.Mba.Host.config | 17 ++ .../FrameworkDependentBundle.wxs | 16 ++ .../LatestCoreBundleFDD.wixproj | 2 + .../LatestCoreBundleSCD.wixproj | 10 + .../LatestCoreBundleSCD/SelfContainedBundle.wxs | 11 + .../Bal/test/examples/LatestCoreBundleSCD/ba.xslt | 20 ++ .../LatestCoreBundleTrimmedSCD.wixproj | 10 + .../TrimmedSelfContainedBundle.wxs | 11 + .../examples/LatestCoreBundleTrimmedSCD/ba.xslt | 20 ++ .../LatestCoreMBA/Example.LatestCoreMBA.csproj | 21 ++ .../test/examples/LatestCoreMBA/LatestCoreBA.cs | 33 +++ .../examples/LatestCoreMBA/LatestCoreBAFactory.cs | 22 ++ .../examples/TestEngine/Example.TestEngine.vcxproj | 83 +++++++ .../test/examples/TestEngine/ExampleTestEngine.cpp | 53 +++++ .../Bal/test/examples/TestEngine/ReloadEngine.cpp | 55 +++++ .../Bal/test/examples/TestEngine/ReloadEngine.h | 8 + .../test/examples/TestEngine/ShutdownEngine.cpp | 38 +++ .../Bal/test/examples/TestEngine/ShutdownEngine.h | 8 + .../Bal/test/examples/TestEngine/TestEngine.cpp | 256 +++++++++++++++++++++ src/ext/Bal/test/examples/TestEngine/TestEngine.h | 80 +++++++ .../test/examples/TestEngine/WaitForQuitEngine.cpp | 35 +++ .../test/examples/TestEngine/WaitForQuitEngine.h | 8 + .../Bal/test/examples/TestEngine/packages.config | 7 + src/ext/Bal/test/examples/TestEngine/precomp.cpp | 3 + src/ext/Bal/test/examples/TestEngine/precomp.h | 20 ++ .../WPFCoreBundleFDD/FrameworkDependentBundle.wxs | 16 ++ .../WPFCoreBundleFDD/WPFCoreBundleFDD.wixproj | 2 + .../Bal/test/examples/WPFCoreMBA/AssemblyInfo.cs | 12 + .../examples/WPFCoreMBA/Example.WPFCoreMBA.csproj | 16 ++ .../Bal/test/examples/WPFCoreMBA/MainWindow.xaml | 16 ++ .../test/examples/WPFCoreMBA/MainWindow.xaml.cs | 17 ++ src/ext/Bal/test/examples/WPFCoreMBA/WPFCoreBA.cs | 42 ++++ .../test/examples/WPFCoreMBA/WPFCoreBAFactory.cs | 22 ++ src/ext/Bal/test/examples/Wix.Build.props | 10 + src/ext/Bal/test/examples/Wix.Build.targets | 8 + src/ext/Bal/test/examples/examples.proj | 50 ++++ 60 files changed, 1447 insertions(+) create mode 100644 src/ext/Bal/test/examples/Directory.Build.props create mode 100644 src/ext/Bal/test/examples/Directory.Build.targets create mode 100644 src/ext/Bal/test/examples/EarliestCoreBundleFDD/EarliestCoreBundleFDD.wixproj create mode 100644 src/ext/Bal/test/examples/EarliestCoreBundleFDD/FrameworkDependentBundle.wxs create mode 100644 src/ext/Bal/test/examples/EarliestCoreBundleSCD/EarliestCoreBundleSCD.wixproj create mode 100644 src/ext/Bal/test/examples/EarliestCoreBundleSCD/SelfContainedBundle.wxs create mode 100644 src/ext/Bal/test/examples/EarliestCoreBundleSCD/ba.xslt create mode 100644 src/ext/Bal/test/examples/EarliestCoreBundleTrimmedSCD/EarliestCoreBundleTrimmedSCD.wixproj create mode 100644 src/ext/Bal/test/examples/EarliestCoreBundleTrimmedSCD/TrimmedSelfContainedBundle.wxs create mode 100644 src/ext/Bal/test/examples/EarliestCoreBundleTrimmedSCD/ba.xslt create mode 100644 src/ext/Bal/test/examples/EarliestCoreMBA/EarliestCoreBA.cs create mode 100644 src/ext/Bal/test/examples/EarliestCoreMBA/EarliestCoreBAFactory.cs create mode 100644 src/ext/Bal/test/examples/EarliestCoreMBA/Example.EarliestCoreMBA.csproj create mode 100644 src/ext/Bal/test/examples/FullFramework2Bundle/Bundle.wxs create mode 100644 src/ext/Bal/test/examples/FullFramework2Bundle/FullFramework2Bundle.wixproj create mode 100644 src/ext/Bal/test/examples/FullFramework2MBA/Example.FullFramework2MBA.csproj create mode 100644 src/ext/Bal/test/examples/FullFramework2MBA/FullFramework2BA.cs create mode 100644 src/ext/Bal/test/examples/FullFramework2MBA/FullFramework2BAFactory.cs create mode 100644 src/ext/Bal/test/examples/FullFramework2MBA/WixToolset.Mba.Host.config create mode 100644 src/ext/Bal/test/examples/FullFramework4Bundle/Bundle.wxs create mode 100644 src/ext/Bal/test/examples/FullFramework4Bundle/FullFramework4Bundle.wixproj create mode 100644 src/ext/Bal/test/examples/FullFramework4MBA/Example.FullFramework4MBA.csproj create mode 100644 src/ext/Bal/test/examples/FullFramework4MBA/FullFramework4BA.cs create mode 100644 src/ext/Bal/test/examples/FullFramework4MBA/FullFramework4BAFactory.cs create mode 100644 src/ext/Bal/test/examples/FullFramework4MBA/WixToolset.Mba.Host.config create mode 100644 src/ext/Bal/test/examples/LatestCoreBundleFDD/FrameworkDependentBundle.wxs create mode 100644 src/ext/Bal/test/examples/LatestCoreBundleFDD/LatestCoreBundleFDD.wixproj create mode 100644 src/ext/Bal/test/examples/LatestCoreBundleSCD/LatestCoreBundleSCD.wixproj create mode 100644 src/ext/Bal/test/examples/LatestCoreBundleSCD/SelfContainedBundle.wxs create mode 100644 src/ext/Bal/test/examples/LatestCoreBundleSCD/ba.xslt create mode 100644 src/ext/Bal/test/examples/LatestCoreBundleTrimmedSCD/LatestCoreBundleTrimmedSCD.wixproj create mode 100644 src/ext/Bal/test/examples/LatestCoreBundleTrimmedSCD/TrimmedSelfContainedBundle.wxs create mode 100644 src/ext/Bal/test/examples/LatestCoreBundleTrimmedSCD/ba.xslt create mode 100644 src/ext/Bal/test/examples/LatestCoreMBA/Example.LatestCoreMBA.csproj create mode 100644 src/ext/Bal/test/examples/LatestCoreMBA/LatestCoreBA.cs create mode 100644 src/ext/Bal/test/examples/LatestCoreMBA/LatestCoreBAFactory.cs create mode 100644 src/ext/Bal/test/examples/TestEngine/Example.TestEngine.vcxproj create mode 100644 src/ext/Bal/test/examples/TestEngine/ExampleTestEngine.cpp create mode 100644 src/ext/Bal/test/examples/TestEngine/ReloadEngine.cpp create mode 100644 src/ext/Bal/test/examples/TestEngine/ReloadEngine.h create mode 100644 src/ext/Bal/test/examples/TestEngine/ShutdownEngine.cpp create mode 100644 src/ext/Bal/test/examples/TestEngine/ShutdownEngine.h create mode 100644 src/ext/Bal/test/examples/TestEngine/TestEngine.cpp create mode 100644 src/ext/Bal/test/examples/TestEngine/TestEngine.h create mode 100644 src/ext/Bal/test/examples/TestEngine/WaitForQuitEngine.cpp create mode 100644 src/ext/Bal/test/examples/TestEngine/WaitForQuitEngine.h create mode 100644 src/ext/Bal/test/examples/TestEngine/packages.config create mode 100644 src/ext/Bal/test/examples/TestEngine/precomp.cpp create mode 100644 src/ext/Bal/test/examples/TestEngine/precomp.h create mode 100644 src/ext/Bal/test/examples/WPFCoreBundleFDD/FrameworkDependentBundle.wxs create mode 100644 src/ext/Bal/test/examples/WPFCoreBundleFDD/WPFCoreBundleFDD.wixproj create mode 100644 src/ext/Bal/test/examples/WPFCoreMBA/AssemblyInfo.cs create mode 100644 src/ext/Bal/test/examples/WPFCoreMBA/Example.WPFCoreMBA.csproj create mode 100644 src/ext/Bal/test/examples/WPFCoreMBA/MainWindow.xaml create mode 100644 src/ext/Bal/test/examples/WPFCoreMBA/MainWindow.xaml.cs create mode 100644 src/ext/Bal/test/examples/WPFCoreMBA/WPFCoreBA.cs create mode 100644 src/ext/Bal/test/examples/WPFCoreMBA/WPFCoreBAFactory.cs create mode 100644 src/ext/Bal/test/examples/Wix.Build.props create mode 100644 src/ext/Bal/test/examples/Wix.Build.targets create mode 100644 src/ext/Bal/test/examples/examples.proj (limited to 'src/ext/Bal/test/examples') diff --git a/src/ext/Bal/test/examples/Directory.Build.props b/src/ext/Bal/test/examples/Directory.Build.props new file mode 100644 index 00000000..3d5870a5 --- /dev/null +++ b/src/ext/Bal/test/examples/Directory.Build.props @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/ext/Bal/test/examples/Directory.Build.targets b/src/ext/Bal/test/examples/Directory.Build.targets new file mode 100644 index 00000000..6dcf402b --- /dev/null +++ b/src/ext/Bal/test/examples/Directory.Build.targets @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/ext/Bal/test/examples/EarliestCoreBundleFDD/EarliestCoreBundleFDD.wixproj b/src/ext/Bal/test/examples/EarliestCoreBundleFDD/EarliestCoreBundleFDD.wixproj new file mode 100644 index 00000000..ba75a9ff --- /dev/null +++ b/src/ext/Bal/test/examples/EarliestCoreBundleFDD/EarliestCoreBundleFDD.wixproj @@ -0,0 +1,2 @@ + + diff --git a/src/ext/Bal/test/examples/EarliestCoreBundleFDD/FrameworkDependentBundle.wxs b/src/ext/Bal/test/examples/EarliestCoreBundleFDD/FrameworkDependentBundle.wxs new file mode 100644 index 00000000..d146845c --- /dev/null +++ b/src/ext/Bal/test/examples/EarliestCoreBundleFDD/FrameworkDependentBundle.wxs @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/src/ext/Bal/test/examples/EarliestCoreBundleSCD/EarliestCoreBundleSCD.wixproj b/src/ext/Bal/test/examples/EarliestCoreBundleSCD/EarliestCoreBundleSCD.wixproj new file mode 100644 index 00000000..ebeebff2 --- /dev/null +++ b/src/ext/Bal/test/examples/EarliestCoreBundleSCD/EarliestCoreBundleSCD.wixproj @@ -0,0 +1,10 @@ + + + + + + publish.Example.EarliestCoreMBA.scd + ba.xslt + + + diff --git a/src/ext/Bal/test/examples/EarliestCoreBundleSCD/SelfContainedBundle.wxs b/src/ext/Bal/test/examples/EarliestCoreBundleSCD/SelfContainedBundle.wxs new file mode 100644 index 00000000..4d872317 --- /dev/null +++ b/src/ext/Bal/test/examples/EarliestCoreBundleSCD/SelfContainedBundle.wxs @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/ext/Bal/test/examples/EarliestCoreBundleSCD/ba.xslt b/src/ext/Bal/test/examples/EarliestCoreBundleSCD/ba.xslt new file mode 100644 index 00000000..06b84256 --- /dev/null +++ b/src/ext/Bal/test/examples/EarliestCoreBundleSCD/ba.xslt @@ -0,0 +1,20 @@ + + + + + + + + + + + + + yes + + + + diff --git a/src/ext/Bal/test/examples/EarliestCoreBundleTrimmedSCD/EarliestCoreBundleTrimmedSCD.wixproj b/src/ext/Bal/test/examples/EarliestCoreBundleTrimmedSCD/EarliestCoreBundleTrimmedSCD.wixproj new file mode 100644 index 00000000..a6b56460 --- /dev/null +++ b/src/ext/Bal/test/examples/EarliestCoreBundleTrimmedSCD/EarliestCoreBundleTrimmedSCD.wixproj @@ -0,0 +1,10 @@ + + + + + + publish.Example.EarliestCoreMBA.trimmedscd + ba.xslt + + + diff --git a/src/ext/Bal/test/examples/EarliestCoreBundleTrimmedSCD/TrimmedSelfContainedBundle.wxs b/src/ext/Bal/test/examples/EarliestCoreBundleTrimmedSCD/TrimmedSelfContainedBundle.wxs new file mode 100644 index 00000000..ba7dce25 --- /dev/null +++ b/src/ext/Bal/test/examples/EarliestCoreBundleTrimmedSCD/TrimmedSelfContainedBundle.wxs @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/ext/Bal/test/examples/EarliestCoreBundleTrimmedSCD/ba.xslt b/src/ext/Bal/test/examples/EarliestCoreBundleTrimmedSCD/ba.xslt new file mode 100644 index 00000000..06b84256 --- /dev/null +++ b/src/ext/Bal/test/examples/EarliestCoreBundleTrimmedSCD/ba.xslt @@ -0,0 +1,20 @@ + + + + + + + + + + + + + yes + + + + diff --git a/src/ext/Bal/test/examples/EarliestCoreMBA/EarliestCoreBA.cs b/src/ext/Bal/test/examples/EarliestCoreMBA/EarliestCoreBA.cs new file mode 100644 index 00000000..c9291a7f --- /dev/null +++ b/src/ext/Bal/test/examples/EarliestCoreMBA/EarliestCoreBA.cs @@ -0,0 +1,34 @@ +// 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. + +namespace Example.EarliestCoreMBA +{ + using WixToolset.Mba.Core; + + public class EarliestCoreBA : BootstrapperApplication + { + public EarliestCoreBA(IEngine engine) + : base(engine) + { + + } + + protected override void Run() + { + } + + protected override void OnStartup(StartupEventArgs args) + { + base.OnStartup(args); + + this.engine.Log(LogLevel.Standard, nameof(EarliestCoreBA)); + } + + protected override void OnShutdown(ShutdownEventArgs args) + { + base.OnShutdown(args); + + var message = "Shutdown," + args.Action.ToString() + "," + args.HResult.ToString(); + this.engine.Log(LogLevel.Standard, message); + } + } +} diff --git a/src/ext/Bal/test/examples/EarliestCoreMBA/EarliestCoreBAFactory.cs b/src/ext/Bal/test/examples/EarliestCoreMBA/EarliestCoreBAFactory.cs new file mode 100644 index 00000000..672e17ee --- /dev/null +++ b/src/ext/Bal/test/examples/EarliestCoreMBA/EarliestCoreBAFactory.cs @@ -0,0 +1,22 @@ +// 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. + +[assembly: WixToolset.Mba.Core.BootstrapperApplicationFactory(typeof(Example.EarliestCoreMBA.EarliestCoreBAFactory))] +namespace Example.EarliestCoreMBA +{ + using WixToolset.Mba.Core; + + public class EarliestCoreBAFactory : BaseBootstrapperApplicationFactory + { + private static int loadCount = 0; + + protected override IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand) + { + if (loadCount > 0) + { + engine.Log(LogLevel.Standard, $"Reloaded {loadCount} time(s)"); + } + ++loadCount; + return new EarliestCoreBA(engine); + } + } +} diff --git a/src/ext/Bal/test/examples/EarliestCoreMBA/Example.EarliestCoreMBA.csproj b/src/ext/Bal/test/examples/EarliestCoreMBA/Example.EarliestCoreMBA.csproj new file mode 100644 index 00000000..cb66c138 --- /dev/null +++ b/src/ext/Bal/test/examples/EarliestCoreMBA/Example.EarliestCoreMBA.csproj @@ -0,0 +1,18 @@ + + + + netcoreapp3.1 + win-x86;win-x64 + true + Earliest .NET Core MBA + + + + + + + + + + + \ No newline at end of file diff --git a/src/ext/Bal/test/examples/FullFramework2Bundle/Bundle.wxs b/src/ext/Bal/test/examples/FullFramework2Bundle/Bundle.wxs new file mode 100644 index 00000000..f0af975c --- /dev/null +++ b/src/ext/Bal/test/examples/FullFramework2Bundle/Bundle.wxs @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/ext/Bal/test/examples/FullFramework2Bundle/FullFramework2Bundle.wixproj b/src/ext/Bal/test/examples/FullFramework2Bundle/FullFramework2Bundle.wixproj new file mode 100644 index 00000000..ba75a9ff --- /dev/null +++ b/src/ext/Bal/test/examples/FullFramework2Bundle/FullFramework2Bundle.wixproj @@ -0,0 +1,2 @@ + + diff --git a/src/ext/Bal/test/examples/FullFramework2MBA/Example.FullFramework2MBA.csproj b/src/ext/Bal/test/examples/FullFramework2MBA/Example.FullFramework2MBA.csproj new file mode 100644 index 00000000..21079ed1 --- /dev/null +++ b/src/ext/Bal/test/examples/FullFramework2MBA/Example.FullFramework2MBA.csproj @@ -0,0 +1,20 @@ + + + + + + net20 + Example.FullFramework2MBA + Example.FullFramework2MBA + embedded + win-x86 + + + + + + + + + + \ No newline at end of file diff --git a/src/ext/Bal/test/examples/FullFramework2MBA/FullFramework2BA.cs b/src/ext/Bal/test/examples/FullFramework2MBA/FullFramework2BA.cs new file mode 100644 index 00000000..32cd19c8 --- /dev/null +++ b/src/ext/Bal/test/examples/FullFramework2MBA/FullFramework2BA.cs @@ -0,0 +1,34 @@ +// 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. + +namespace Example.FullFramework2MBA +{ + using WixToolset.Mba.Core; + + public class FullFramework2BA : BootstrapperApplication + { + public FullFramework2BA(IEngine engine) + : base(engine) + { + + } + + protected override void Run() + { + } + + protected override void OnStartup(StartupEventArgs args) + { + base.OnStartup(args); + + this.engine.Log(LogLevel.Standard, nameof(FullFramework2BA)); + } + + protected override void OnShutdown(ShutdownEventArgs args) + { + base.OnShutdown(args); + + var message = "Shutdown," + args.Action.ToString() + "," + args.HResult.ToString(); + this.engine.Log(LogLevel.Standard, message); + } + } +} diff --git a/src/ext/Bal/test/examples/FullFramework2MBA/FullFramework2BAFactory.cs b/src/ext/Bal/test/examples/FullFramework2MBA/FullFramework2BAFactory.cs new file mode 100644 index 00000000..647c2040 --- /dev/null +++ b/src/ext/Bal/test/examples/FullFramework2MBA/FullFramework2BAFactory.cs @@ -0,0 +1,22 @@ +// 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. + +[assembly: WixToolset.Mba.Core.BootstrapperApplicationFactory(typeof(Example.FullFramework2MBA.FullFramework2BAFactory))] +namespace Example.FullFramework2MBA +{ + using WixToolset.Mba.Core; + + public class FullFramework2BAFactory : BaseBootstrapperApplicationFactory + { + private static int loadCount = 0; + + protected override IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand) + { + if (loadCount > 0) + { + engine.Log(LogLevel.Standard, $"Reloaded {loadCount} time(s)"); + } + ++loadCount; + return new FullFramework2BA(engine); + } + } +} diff --git a/src/ext/Bal/test/examples/FullFramework2MBA/WixToolset.Mba.Host.config b/src/ext/Bal/test/examples/FullFramework2MBA/WixToolset.Mba.Host.config new file mode 100644 index 00000000..be450a4f --- /dev/null +++ b/src/ext/Bal/test/examples/FullFramework2MBA/WixToolset.Mba.Host.config @@ -0,0 +1,20 @@ + + + + + + + +
+ + + + + + + + + + + + diff --git a/src/ext/Bal/test/examples/FullFramework4Bundle/Bundle.wxs b/src/ext/Bal/test/examples/FullFramework4Bundle/Bundle.wxs new file mode 100644 index 00000000..7b7cbf57 --- /dev/null +++ b/src/ext/Bal/test/examples/FullFramework4Bundle/Bundle.wxs @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/ext/Bal/test/examples/FullFramework4Bundle/FullFramework4Bundle.wixproj b/src/ext/Bal/test/examples/FullFramework4Bundle/FullFramework4Bundle.wixproj new file mode 100644 index 00000000..ba75a9ff --- /dev/null +++ b/src/ext/Bal/test/examples/FullFramework4Bundle/FullFramework4Bundle.wixproj @@ -0,0 +1,2 @@ + + diff --git a/src/ext/Bal/test/examples/FullFramework4MBA/Example.FullFramework4MBA.csproj b/src/ext/Bal/test/examples/FullFramework4MBA/Example.FullFramework4MBA.csproj new file mode 100644 index 00000000..a05e7888 --- /dev/null +++ b/src/ext/Bal/test/examples/FullFramework4MBA/Example.FullFramework4MBA.csproj @@ -0,0 +1,19 @@ + + + + + + net48 + Full Framework v4 MBA + win-x86 + + + + + + + + + + + \ No newline at end of file diff --git a/src/ext/Bal/test/examples/FullFramework4MBA/FullFramework4BA.cs b/src/ext/Bal/test/examples/FullFramework4MBA/FullFramework4BA.cs new file mode 100644 index 00000000..8ee3bd19 --- /dev/null +++ b/src/ext/Bal/test/examples/FullFramework4MBA/FullFramework4BA.cs @@ -0,0 +1,34 @@ +// 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. + +namespace Example.FullFramework4MBA +{ + using WixToolset.Mba.Core; + + public class FullFramework4BA : BootstrapperApplication + { + public FullFramework4BA(IEngine engine) + : base(engine) + { + + } + + protected override void Run() + { + } + + protected override void OnStartup(StartupEventArgs args) + { + base.OnStartup(args); + + this.engine.Log(LogLevel.Standard, nameof(FullFramework4BA)); + } + + protected override void OnShutdown(ShutdownEventArgs args) + { + base.OnShutdown(args); + + var message = "Shutdown," + args.Action.ToString() + "," + args.HResult.ToString(); + this.engine.Log(LogLevel.Standard, message); + } + } +} diff --git a/src/ext/Bal/test/examples/FullFramework4MBA/FullFramework4BAFactory.cs b/src/ext/Bal/test/examples/FullFramework4MBA/FullFramework4BAFactory.cs new file mode 100644 index 00000000..6a571a54 --- /dev/null +++ b/src/ext/Bal/test/examples/FullFramework4MBA/FullFramework4BAFactory.cs @@ -0,0 +1,22 @@ +// 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. + +[assembly: WixToolset.Mba.Core.BootstrapperApplicationFactory(typeof(Example.FullFramework4MBA.FullFramework4BAFactory))] +namespace Example.FullFramework4MBA +{ + using WixToolset.Mba.Core; + + public class FullFramework4BAFactory : BaseBootstrapperApplicationFactory + { + private static int loadCount = 0; + + protected override IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand) + { + if (loadCount > 0) + { + engine.Log(LogLevel.Standard, $"Reloaded {loadCount} time(s)"); + } + ++loadCount; + return new FullFramework4BA(engine); + } + } +} diff --git a/src/ext/Bal/test/examples/FullFramework4MBA/WixToolset.Mba.Host.config b/src/ext/Bal/test/examples/FullFramework4MBA/WixToolset.Mba.Host.config new file mode 100644 index 00000000..96678cda --- /dev/null +++ b/src/ext/Bal/test/examples/FullFramework4MBA/WixToolset.Mba.Host.config @@ -0,0 +1,17 @@ + + + + + + + +
+ + + + + + + + + diff --git a/src/ext/Bal/test/examples/LatestCoreBundleFDD/FrameworkDependentBundle.wxs b/src/ext/Bal/test/examples/LatestCoreBundleFDD/FrameworkDependentBundle.wxs new file mode 100644 index 00000000..d5b543e8 --- /dev/null +++ b/src/ext/Bal/test/examples/LatestCoreBundleFDD/FrameworkDependentBundle.wxs @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/src/ext/Bal/test/examples/LatestCoreBundleFDD/LatestCoreBundleFDD.wixproj b/src/ext/Bal/test/examples/LatestCoreBundleFDD/LatestCoreBundleFDD.wixproj new file mode 100644 index 00000000..ba75a9ff --- /dev/null +++ b/src/ext/Bal/test/examples/LatestCoreBundleFDD/LatestCoreBundleFDD.wixproj @@ -0,0 +1,2 @@ + + diff --git a/src/ext/Bal/test/examples/LatestCoreBundleSCD/LatestCoreBundleSCD.wixproj b/src/ext/Bal/test/examples/LatestCoreBundleSCD/LatestCoreBundleSCD.wixproj new file mode 100644 index 00000000..30a860ab --- /dev/null +++ b/src/ext/Bal/test/examples/LatestCoreBundleSCD/LatestCoreBundleSCD.wixproj @@ -0,0 +1,10 @@ + + + + + + publish.Example.LatestCoreMBA.scd + ba.xslt + + + diff --git a/src/ext/Bal/test/examples/LatestCoreBundleSCD/SelfContainedBundle.wxs b/src/ext/Bal/test/examples/LatestCoreBundleSCD/SelfContainedBundle.wxs new file mode 100644 index 00000000..bedf0326 --- /dev/null +++ b/src/ext/Bal/test/examples/LatestCoreBundleSCD/SelfContainedBundle.wxs @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/ext/Bal/test/examples/LatestCoreBundleSCD/ba.xslt b/src/ext/Bal/test/examples/LatestCoreBundleSCD/ba.xslt new file mode 100644 index 00000000..acc7474c --- /dev/null +++ b/src/ext/Bal/test/examples/LatestCoreBundleSCD/ba.xslt @@ -0,0 +1,20 @@ + + + + + + + + + + + + + yes + + + + diff --git a/src/ext/Bal/test/examples/LatestCoreBundleTrimmedSCD/LatestCoreBundleTrimmedSCD.wixproj b/src/ext/Bal/test/examples/LatestCoreBundleTrimmedSCD/LatestCoreBundleTrimmedSCD.wixproj new file mode 100644 index 00000000..5ce89b64 --- /dev/null +++ b/src/ext/Bal/test/examples/LatestCoreBundleTrimmedSCD/LatestCoreBundleTrimmedSCD.wixproj @@ -0,0 +1,10 @@ + + + + + + publish.Example.LatestCoreMBA.trimmedscd + ba.xslt + + + diff --git a/src/ext/Bal/test/examples/LatestCoreBundleTrimmedSCD/TrimmedSelfContainedBundle.wxs b/src/ext/Bal/test/examples/LatestCoreBundleTrimmedSCD/TrimmedSelfContainedBundle.wxs new file mode 100644 index 00000000..6059f8c1 --- /dev/null +++ b/src/ext/Bal/test/examples/LatestCoreBundleTrimmedSCD/TrimmedSelfContainedBundle.wxs @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/ext/Bal/test/examples/LatestCoreBundleTrimmedSCD/ba.xslt b/src/ext/Bal/test/examples/LatestCoreBundleTrimmedSCD/ba.xslt new file mode 100644 index 00000000..acc7474c --- /dev/null +++ b/src/ext/Bal/test/examples/LatestCoreBundleTrimmedSCD/ba.xslt @@ -0,0 +1,20 @@ + + + + + + + + + + + + + yes + + + + diff --git a/src/ext/Bal/test/examples/LatestCoreMBA/Example.LatestCoreMBA.csproj b/src/ext/Bal/test/examples/LatestCoreMBA/Example.LatestCoreMBA.csproj new file mode 100644 index 00000000..9f3f02d9 --- /dev/null +++ b/src/ext/Bal/test/examples/LatestCoreMBA/Example.LatestCoreMBA.csproj @@ -0,0 +1,21 @@ + + + + net5.0 + win-x86;win-x64 + true + Latest .NET Core MBA + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/ext/Bal/test/examples/LatestCoreMBA/LatestCoreBA.cs b/src/ext/Bal/test/examples/LatestCoreMBA/LatestCoreBA.cs new file mode 100644 index 00000000..50386a87 --- /dev/null +++ b/src/ext/Bal/test/examples/LatestCoreMBA/LatestCoreBA.cs @@ -0,0 +1,33 @@ +// 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. + +namespace Example.LatestCoreMBA +{ + using WixToolset.Mba.Core; + + public class LatestCoreBA : BootstrapperApplication + { + public LatestCoreBA(IEngine engine) + : base(engine) + { + } + + protected override void Run() + { + } + + protected override void OnStartup(StartupEventArgs args) + { + base.OnStartup(args); + + this.engine.Log(LogLevel.Standard, nameof(LatestCoreBA)); + } + + protected override void OnShutdown(ShutdownEventArgs args) + { + base.OnShutdown(args); + + var message = "Shutdown," + args.Action.ToString() + "," + args.HResult.ToString(); + this.engine.Log(LogLevel.Standard, message); + } + } +} diff --git a/src/ext/Bal/test/examples/LatestCoreMBA/LatestCoreBAFactory.cs b/src/ext/Bal/test/examples/LatestCoreMBA/LatestCoreBAFactory.cs new file mode 100644 index 00000000..fff3b5c5 --- /dev/null +++ b/src/ext/Bal/test/examples/LatestCoreMBA/LatestCoreBAFactory.cs @@ -0,0 +1,22 @@ +// 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. + +[assembly: WixToolset.Mba.Core.BootstrapperApplicationFactory(typeof(Example.LatestCoreMBA.LatestCoreBAFactory))] +namespace Example.LatestCoreMBA +{ + using WixToolset.Mba.Core; + + public class LatestCoreBAFactory : BaseBootstrapperApplicationFactory + { + private static int loadCount = 0; + + protected override IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand) + { + if (loadCount > 0) + { + engine.Log(LogLevel.Standard, $"Reloaded {loadCount} time(s)"); + } + ++loadCount; + return new LatestCoreBA(engine); + } + } +} diff --git a/src/ext/Bal/test/examples/TestEngine/Example.TestEngine.vcxproj b/src/ext/Bal/test/examples/TestEngine/Example.TestEngine.vcxproj new file mode 100644 index 00000000..99eb917e --- /dev/null +++ b/src/ext/Bal/test/examples/TestEngine/Example.TestEngine.vcxproj @@ -0,0 +1,83 @@ + + + + + + + + + Debug + ARM64 + + + Release + ARM64 + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {3D44B67D-A475-49BA-8310-E39F6C117CC9} + Application + Console + Example.TestEngine + v142 + Unicode + 10.0 + + + + + + + + + + + + + + + Create + + + + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + \ No newline at end of file diff --git a/src/ext/Bal/test/examples/TestEngine/ExampleTestEngine.cpp b/src/ext/Bal/test/examples/TestEngine/ExampleTestEngine.cpp new file mode 100644 index 00000000..fc1938fe --- /dev/null +++ b/src/ext/Bal/test/examples/TestEngine/ExampleTestEngine.cpp @@ -0,0 +1,53 @@ +// 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. + +#include "precomp.h" + +int __cdecl wmain(int argc, LPWSTR argv[]) +{ + HRESULT hr = S_OK; + BOOL fComInitialized = FALSE; + BOOL fShowUsage = FALSE; + + // initialize COM + hr = ::CoInitializeEx(NULL, COINIT_MULTITHREADED); + ExitOnFailure(hr, "Failed to initialize COM."); + fComInitialized = TRUE; + + ConsoleInitialize(); + + if (argc != 4) + { + fShowUsage = TRUE; + } + else if (CSTR_EQUAL == ::CompareString(LOCALE_INVARIANT, NORM_IGNORECASE, argv[1], -1, L"reload", -1)) + { + hr = RunReloadEngine(argv[2], argv[3]); + } + else if (CSTR_EQUAL == ::CompareString(LOCALE_INVARIANT, NORM_IGNORECASE, argv[1], -1, L"shutdown", -1)) + { + hr = RunShutdownEngine(argv[2], argv[3]); + } + else if (CSTR_EQUAL == ::CompareString(LOCALE_INVARIANT, NORM_IGNORECASE, argv[1], -1, L"waitforquit", -1)) + { + hr = RunWaitForQuitEngine(argv[2], argv[3]); + } + else + { + fShowUsage = TRUE; + } + + if (fShowUsage) + { + ConsoleWriteError(hr = E_INVALIDARG, CONSOLE_COLOR_RED, "Usage: Example.TestEngine.exe {reload|shutdown|waitforquit} Bundle.exe BA.dll"); + } + + ConsoleUninitialize(); + +LExit: + if (fComInitialized) + { + ::CoUninitialize(); + } + + return hr; +} diff --git a/src/ext/Bal/test/examples/TestEngine/ReloadEngine.cpp b/src/ext/Bal/test/examples/TestEngine/ReloadEngine.cpp new file mode 100644 index 00000000..46fd9afa --- /dev/null +++ b/src/ext/Bal/test/examples/TestEngine/ReloadEngine.cpp @@ -0,0 +1,55 @@ +// 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. + +#include "precomp.h" + +HRESULT RunReloadEngine( + __in LPCWSTR wzBundleFilePath, + __in LPCWSTR wzBAFilePath + ) +{ + HRESULT hr = S_OK; + TestEngine* pTestEngine = NULL; + + pTestEngine = new TestEngine(); + ConsoleExitOnNull(pTestEngine, hr, E_OUTOFMEMORY, CONSOLE_COLOR_RED, "Failed to create new test engine."); + + hr = pTestEngine->Initialize(wzBundleFilePath); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to initialize engine."); + + hr = pTestEngine->LoadBA(wzBAFilePath); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to load BA."); + + hr = pTestEngine->SendStartupEvent(); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure for OnStartup."); + + hr = pTestEngine->SimulateQuit(0); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to simulate quit."); + + hr = pTestEngine->RunApplication(); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to run engine."); + + hr = pTestEngine->SendShutdownEvent(BOOTSTRAPPER_SHUTDOWN_ACTION_RELOAD_BOOTSTRAPPER); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure for OnShutdown."); + + pTestEngine->UnloadBA(); + + hr = pTestEngine->LoadBA(wzBAFilePath); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to load BA."); + + hr = pTestEngine->SendStartupEvent(); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure for OnStartup."); + + hr = pTestEngine->SimulateQuit(0); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to simulate quit."); + + hr = pTestEngine->RunApplication(); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to run engine."); + + hr = pTestEngine->SendShutdownEvent(BOOTSTRAPPER_SHUTDOWN_ACTION_RESTART); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure for OnShutdown."); + + pTestEngine->UnloadBA(); + +LExit: + return hr; +} diff --git a/src/ext/Bal/test/examples/TestEngine/ReloadEngine.h b/src/ext/Bal/test/examples/TestEngine/ReloadEngine.h new file mode 100644 index 00000000..0e8456af --- /dev/null +++ b/src/ext/Bal/test/examples/TestEngine/ReloadEngine.h @@ -0,0 +1,8 @@ +#pragma once +// 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. + + +HRESULT RunReloadEngine( + __in LPCWSTR wzBundleFilePath, + __in LPCWSTR wzBAFilePath + ); diff --git a/src/ext/Bal/test/examples/TestEngine/ShutdownEngine.cpp b/src/ext/Bal/test/examples/TestEngine/ShutdownEngine.cpp new file mode 100644 index 00000000..3b876e4e --- /dev/null +++ b/src/ext/Bal/test/examples/TestEngine/ShutdownEngine.cpp @@ -0,0 +1,38 @@ +// 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. + +#include "precomp.h" + +HRESULT RunShutdownEngine( + __in LPCWSTR wzBundleFilePath, + __in LPCWSTR wzBAFilePath + ) +{ + HRESULT hr = S_OK; + TestEngine* pTestEngine = NULL; + + pTestEngine = new TestEngine(); + ConsoleExitOnNull(pTestEngine, hr, E_OUTOFMEMORY, CONSOLE_COLOR_RED, "Failed to create new test engine."); + + hr = pTestEngine->Initialize(wzBundleFilePath); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to initialize engine."); + + hr = pTestEngine->LoadBA(wzBAFilePath); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to load BA."); + + hr = pTestEngine->SendStartupEvent(); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure for OnStartup."); + + hr = pTestEngine->SimulateQuit(0); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to simulate quit."); + + hr = pTestEngine->RunApplication(); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to run engine."); + + hr = pTestEngine->SendShutdownEvent(BOOTSTRAPPER_SHUTDOWN_ACTION_RELOAD_BOOTSTRAPPER); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure for OnShutdown."); + + pTestEngine->UnloadBA(); + +LExit: + return hr; +} diff --git a/src/ext/Bal/test/examples/TestEngine/ShutdownEngine.h b/src/ext/Bal/test/examples/TestEngine/ShutdownEngine.h new file mode 100644 index 00000000..0cfa147a --- /dev/null +++ b/src/ext/Bal/test/examples/TestEngine/ShutdownEngine.h @@ -0,0 +1,8 @@ +#pragma once +// 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. + + +HRESULT RunShutdownEngine( + __in LPCWSTR wzBundleFilePath, + __in LPCWSTR wzBAFilePath + ); diff --git a/src/ext/Bal/test/examples/TestEngine/TestEngine.cpp b/src/ext/Bal/test/examples/TestEngine/TestEngine.cpp new file mode 100644 index 00000000..4c7ec1c3 --- /dev/null +++ b/src/ext/Bal/test/examples/TestEngine/TestEngine.cpp @@ -0,0 +1,256 @@ +// 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. + +#include "precomp.h" + +HRESULT TestEngine::Initialize( + __in LPCWSTR wzBundleFilePath + ) +{ + HRESULT hr = S_OK; + MSG msg = { }; + + LogInitialize(::GetModuleHandleW(NULL)); + + hr = LogOpen(NULL, PathFile(wzBundleFilePath), NULL, L"txt", FALSE, FALSE, NULL); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to open log."); + + ::PeekMessageW(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE); + +LExit: + return hr; +} + +HRESULT TestEngine::LoadBA( + __in LPCWSTR wzBAFilePath + ) +{ + HRESULT hr = S_OK; + BOOTSTRAPPER_COMMAND command = { }; + BOOTSTRAPPER_CREATE_ARGS args = { }; + PFN_BOOTSTRAPPER_APPLICATION_CREATE pfnCreate = NULL; + + if (m_pCreateResults || m_hBAModule) + { + ExitFunction1(hr = E_INVALIDSTATE); + } + + m_pCreateResults = static_cast(MemAlloc(sizeof(BOOTSTRAPPER_CREATE_RESULTS), TRUE)); + + command.cbSize = sizeof(BOOTSTRAPPER_COMMAND); + + hr = PathGetDirectory(wzBAFilePath, &command.wzBootstrapperWorkingFolder); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to allocate wzBootstrapperWorkingFolder"); + + hr = PathConcat(command.wzBootstrapperWorkingFolder, L"BootstrapperApplicationData.xml", &command.wzBootstrapperApplicationDataPath); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to allocate wzBootstrapperApplicationDataPath"); + + args.cbSize = sizeof(BOOTSTRAPPER_CREATE_ARGS); + args.pCommand = &command; + args.pfnBootstrapperEngineProc = TestEngine::EngineProc; + args.pvBootstrapperEngineProcContext = this; + args.qwEngineAPIVersion = MAKEQWORDVERSION(0, 0, 0, 1); + + m_pCreateResults->cbSize = sizeof(BOOTSTRAPPER_CREATE_RESULTS); + + m_hBAModule = ::LoadLibraryExW(wzBAFilePath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); + ConsoleExitOnNullWithLastError(m_hBAModule, hr, CONSOLE_COLOR_RED, "Failed to load BA dll."); + + pfnCreate = (PFN_BOOTSTRAPPER_APPLICATION_CREATE)::GetProcAddress(m_hBAModule, "BootstrapperApplicationCreate"); + ConsoleExitOnNull(pfnCreate, hr, E_OUTOFMEMORY, CONSOLE_COLOR_RED, "Failed to get address for BootstrapperApplicationCreate."); + + hr = pfnCreate(&args, m_pCreateResults); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure on BootstrapperApplicationCreate."); + +LExit: + ReleaseStr(command.wzBootstrapperApplicationDataPath); + ReleaseStr(command.wzBootstrapperWorkingFolder); + + return hr; +} + +HRESULT TestEngine::Log( + __in BOOTSTRAPPER_LOG_LEVEL level, + __in LPCWSTR wzMessage + ) +{ + switch (level) + { + case BOOTSTRAPPER_LOG_LEVEL_NONE: + case BOOTSTRAPPER_LOG_LEVEL_DEBUG: + return S_OK; + default: + LogStringLine(REPORT_STANDARD, "%ls", wzMessage); + return ConsoleWriteLine(CONSOLE_COLOR_NORMAL, "%ls", wzMessage); + } +} + +HRESULT TestEngine::RunApplication() +{ + HRESULT hr = S_OK; + MSG msg = { }; + BOOL fRet = FALSE; + + // Enter the message pump. + while (0 != (fRet = ::GetMessageW(&msg, NULL, 0, 0))) + { + if (-1 == fRet) + { + ConsoleExitOnFailure(hr = E_UNEXPECTED, CONSOLE_COLOR_RED, "Unexpected return value from message pump."); + } + else + { + ProcessBAMessage(&msg); + } + } + +LExit: + return hr; +} + +HRESULT TestEngine::SendShutdownEvent( + __in BOOTSTRAPPER_SHUTDOWN_ACTION defaultAction + ) +{ + HRESULT hr = S_OK; + BA_ONSHUTDOWN_ARGS shutdownArgs = { }; + BA_ONSHUTDOWN_RESULTS shutdownResults = { }; + shutdownArgs.cbSize = sizeof(BA_ONSHUTDOWN_ARGS); + shutdownResults.action = defaultAction; + shutdownResults.cbSize = sizeof(BA_ONSHUTDOWN_RESULTS); + hr = m_pCreateResults->pfnBootstrapperApplicationProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONSHUTDOWN, &shutdownArgs, &shutdownResults, m_pCreateResults->pvBootstrapperApplicationProcContext); + return hr; +} + +HRESULT TestEngine::SendStartupEvent() +{ + HRESULT hr = S_OK; + BA_ONSTARTUP_ARGS startupArgs = { }; + BA_ONSTARTUP_RESULTS startupResults = { }; + startupArgs.cbSize = sizeof(BA_ONSTARTUP_ARGS); + startupResults.cbSize = sizeof(BA_ONSTARTUP_RESULTS); + hr = m_pCreateResults->pfnBootstrapperApplicationProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONSTARTUP, &startupArgs, &startupResults, m_pCreateResults->pvBootstrapperApplicationProcContext); + return hr; +} + +HRESULT TestEngine::SimulateQuit( + __in DWORD dwExitCode + ) +{ + BAENGINE_QUIT_ARGS args = { }; + BAENGINE_QUIT_RESULTS results = { }; + + args.cbSize = sizeof(BAENGINE_QUIT_ARGS); + args.dwExitCode = dwExitCode; + + results.cbSize = sizeof(BAENGINE_QUIT_RESULTS); + + return BAEngineQuit(&args, &results); +} + +void TestEngine::UnloadBA() +{ + PFN_BOOTSTRAPPER_APPLICATION_DESTROY pfnDestroy = NULL; + BOOL fDisableUnloading = m_pCreateResults && m_pCreateResults->fDisableUnloading; + + ReleaseNullMem(m_pCreateResults); + + pfnDestroy = (PFN_BOOTSTRAPPER_APPLICATION_DESTROY)::GetProcAddress(m_hBAModule, "BootstrapperApplicationDestroy"); + + if (pfnDestroy) + { + pfnDestroy(); + } + + if (m_hBAModule) + { + if (!fDisableUnloading) + { + ::FreeLibrary(m_hBAModule); + } + + m_hBAModule = NULL; + } +} + +HRESULT TestEngine::BAEngineLog( + __in BAENGINE_LOG_ARGS* pArgs, + __in BAENGINE_LOG_RESULTS* /*pResults*/ + ) +{ + return Log(pArgs->level, pArgs->wzMessage); +} + +HRESULT TestEngine::BAEngineQuit( + __in BAENGINE_QUIT_ARGS* pArgs, + __in BAENGINE_QUIT_RESULTS* /*pResults*/ + ) +{ + HRESULT hr = S_OK; + + if (!::PostThreadMessageW(m_dwThreadId, WM_TESTENG_QUIT, static_cast(pArgs->dwExitCode), 0)) + { + ConsoleExitWithLastError(hr, CONSOLE_COLOR_RED, "Failed to post shutdown message."); + } + +LExit: + return hr; +} + +HRESULT WINAPI TestEngine::EngineProc( + __in BOOTSTRAPPER_ENGINE_MESSAGE message, + __in const LPVOID pvArgs, + __inout LPVOID pvResults, + __in_opt LPVOID pvContext + ) +{ + HRESULT hr = S_OK; + TestEngine* pContext = (TestEngine*)pvContext; + + if (!pContext || !pvArgs || !pvResults) + { + ExitFunction1(hr = E_INVALIDARG); + } + + switch (message) + { + case BOOTSTRAPPER_ENGINE_MESSAGE_LOG: + hr = pContext->BAEngineLog(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_ENGINE_MESSAGE_QUIT: + hr = pContext->BAEngineQuit(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + default: + hr = E_NOTIMPL; + break; + } + +LExit: + return hr; +} + +HRESULT TestEngine::ProcessBAMessage( + __in const MSG* pmsg + ) +{ + HRESULT hr = S_OK; + + switch (pmsg->message) + { + case WM_TESTENG_QUIT: + ::PostQuitMessage(static_cast(pmsg->wParam)); // go bye-bye. + break; + } + + return hr; +} + +TestEngine::TestEngine() +{ + m_hBAModule = NULL; + m_pCreateResults = NULL; + m_dwThreadId = ::GetCurrentThreadId(); +} + +TestEngine::~TestEngine() +{ + ReleaseMem(m_pCreateResults); +} diff --git a/src/ext/Bal/test/examples/TestEngine/TestEngine.h b/src/ext/Bal/test/examples/TestEngine/TestEngine.h new file mode 100644 index 00000000..44e813bd --- /dev/null +++ b/src/ext/Bal/test/examples/TestEngine/TestEngine.h @@ -0,0 +1,80 @@ +#pragma once +// 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. + + +enum WM_TESTENG +{ + WM_TESTENG_FIRST = WM_APP + 0xFFF, // this enum value must always be first. + + WM_TESTENG_DETECT, + WM_TESTENG_PLAN, + WM_TESTENG_ELEVATE, + WM_TESTENG_APPLY, + WM_TESTENG_LAUNCH_APPROVED_EXE, + WM_TESTENG_QUIT, + + WM_TESTENG_LAST, // this enum value must always be last. +}; + +class TestEngine +{ +public: + HRESULT Initialize( + __in LPCWSTR wzBundleFilePath + ); + + HRESULT LoadBA( + __in LPCWSTR wzBAFilePath + ); + + HRESULT Log( + __in BOOTSTRAPPER_LOG_LEVEL level, + __in LPCWSTR wzMessage + ); + + HRESULT RunApplication(); + + HRESULT SendShutdownEvent( + __in BOOTSTRAPPER_SHUTDOWN_ACTION defaultAction + ); + + HRESULT SendStartupEvent(); + + HRESULT SimulateQuit( + __in DWORD dwExitCode + ); + + void UnloadBA(); + +private: + HRESULT BAEngineLog( + __in BAENGINE_LOG_ARGS* pArgs, + __in BAENGINE_LOG_RESULTS* pResults + ); + + HRESULT BAEngineQuit( + __in BAENGINE_QUIT_ARGS* pArgs, + __in BAENGINE_QUIT_RESULTS* pResults + ); + + static HRESULT WINAPI EngineProc( + __in BOOTSTRAPPER_ENGINE_MESSAGE message, + __in const LPVOID pvArgs, + __inout LPVOID pvResults, + __in_opt LPVOID pvContext + ); + + HRESULT ProcessBAMessage( + __in const MSG* pmsg + ); + +public: + TestEngine(); + + ~TestEngine(); + +private: + HMODULE m_hBAModule; + BOOTSTRAPPER_CREATE_RESULTS* m_pCreateResults; + DWORD m_dwThreadId; +}; \ No newline at end of file diff --git a/src/ext/Bal/test/examples/TestEngine/WaitForQuitEngine.cpp b/src/ext/Bal/test/examples/TestEngine/WaitForQuitEngine.cpp new file mode 100644 index 00000000..2f80ba75 --- /dev/null +++ b/src/ext/Bal/test/examples/TestEngine/WaitForQuitEngine.cpp @@ -0,0 +1,35 @@ +// 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. + +#include "precomp.h" + +HRESULT RunWaitForQuitEngine( + __in LPCWSTR wzBundleFilePath, + __in LPCWSTR wzBAFilePath + ) +{ + HRESULT hr = S_OK; + TestEngine* pTestEngine = NULL; + + pTestEngine = new TestEngine(); + ConsoleExitOnNull(pTestEngine, hr, E_OUTOFMEMORY, CONSOLE_COLOR_RED, "Failed to create new test engine."); + + hr = pTestEngine->Initialize(wzBundleFilePath); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to initialize engine."); + + hr = pTestEngine->LoadBA(wzBAFilePath); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to load BA."); + + hr = pTestEngine->SendStartupEvent(); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure for OnStartup."); + + hr = pTestEngine->RunApplication(); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to run engine."); + + hr = pTestEngine->SendShutdownEvent(BOOTSTRAPPER_SHUTDOWN_ACTION_RELOAD_BOOTSTRAPPER); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure for OnShutdown."); + + pTestEngine->UnloadBA(); + +LExit: + return hr; +} diff --git a/src/ext/Bal/test/examples/TestEngine/WaitForQuitEngine.h b/src/ext/Bal/test/examples/TestEngine/WaitForQuitEngine.h new file mode 100644 index 00000000..99e3f63c --- /dev/null +++ b/src/ext/Bal/test/examples/TestEngine/WaitForQuitEngine.h @@ -0,0 +1,8 @@ +#pragma once +// 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. + + +HRESULT RunWaitForQuitEngine( + __in LPCWSTR wzBundleFilePath, + __in LPCWSTR wzBAFilePath + ); diff --git a/src/ext/Bal/test/examples/TestEngine/packages.config b/src/ext/Bal/test/examples/TestEngine/packages.config new file mode 100644 index 00000000..548ddb48 --- /dev/null +++ b/src/ext/Bal/test/examples/TestEngine/packages.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/src/ext/Bal/test/examples/TestEngine/precomp.cpp b/src/ext/Bal/test/examples/TestEngine/precomp.cpp new file mode 100644 index 00000000..37664a1c --- /dev/null +++ b/src/ext/Bal/test/examples/TestEngine/precomp.cpp @@ -0,0 +1,3 @@ +// 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. + +#include "precomp.h" diff --git a/src/ext/Bal/test/examples/TestEngine/precomp.h b/src/ext/Bal/test/examples/TestEngine/precomp.h new file mode 100644 index 00000000..f943f420 --- /dev/null +++ b/src/ext/Bal/test/examples/TestEngine/precomp.h @@ -0,0 +1,20 @@ +#pragma once +// 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. + +#include +#include + +#include "dutil.h" +#include "conutil.h" +#include "logutil.h" +#include "memutil.h" +#include "pathutil.h" +#include "strutil.h" + +#include "BootstrapperEngine.h" +#include "BootstrapperApplication.h" + +#include "TestEngine.h" +#include "ReloadEngine.h" +#include "ShutdownEngine.h" +#include "WaitForQuitEngine.h" diff --git a/src/ext/Bal/test/examples/WPFCoreBundleFDD/FrameworkDependentBundle.wxs b/src/ext/Bal/test/examples/WPFCoreBundleFDD/FrameworkDependentBundle.wxs new file mode 100644 index 00000000..68d742b0 --- /dev/null +++ b/src/ext/Bal/test/examples/WPFCoreBundleFDD/FrameworkDependentBundle.wxs @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/src/ext/Bal/test/examples/WPFCoreBundleFDD/WPFCoreBundleFDD.wixproj b/src/ext/Bal/test/examples/WPFCoreBundleFDD/WPFCoreBundleFDD.wixproj new file mode 100644 index 00000000..ba75a9ff --- /dev/null +++ b/src/ext/Bal/test/examples/WPFCoreBundleFDD/WPFCoreBundleFDD.wixproj @@ -0,0 +1,2 @@ + + diff --git a/src/ext/Bal/test/examples/WPFCoreMBA/AssemblyInfo.cs b/src/ext/Bal/test/examples/WPFCoreMBA/AssemblyInfo.cs new file mode 100644 index 00000000..03a5c7fa --- /dev/null +++ b/src/ext/Bal/test/examples/WPFCoreMBA/AssemblyInfo.cs @@ -0,0 +1,12 @@ +// 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. + +using System.Windows; + +[assembly:ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/src/ext/Bal/test/examples/WPFCoreMBA/Example.WPFCoreMBA.csproj b/src/ext/Bal/test/examples/WPFCoreMBA/Example.WPFCoreMBA.csproj new file mode 100644 index 00000000..296e5be9 --- /dev/null +++ b/src/ext/Bal/test/examples/WPFCoreMBA/Example.WPFCoreMBA.csproj @@ -0,0 +1,16 @@ + + + + net5.0-windows + win-x86;win-x64 + true + WPF .NET Core MBA + true + + + + + + + + \ No newline at end of file diff --git a/src/ext/Bal/test/examples/WPFCoreMBA/MainWindow.xaml b/src/ext/Bal/test/examples/WPFCoreMBA/MainWindow.xaml new file mode 100644 index 00000000..40a27a06 --- /dev/null +++ b/src/ext/Bal/test/examples/WPFCoreMBA/MainWindow.xaml @@ -0,0 +1,16 @@ + + + + + + + + + diff --git a/src/ext/Bal/test/examples/WPFCoreMBA/MainWindow.xaml.cs b/src/ext/Bal/test/examples/WPFCoreMBA/MainWindow.xaml.cs new file mode 100644 index 00000000..4f61b807 --- /dev/null +++ b/src/ext/Bal/test/examples/WPFCoreMBA/MainWindow.xaml.cs @@ -0,0 +1,17 @@ +// 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. + +namespace Example.WPFCoreMBA +{ + using System.Windows; + + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + public MainWindow() + { + this.InitializeComponent(); + } + } +} diff --git a/src/ext/Bal/test/examples/WPFCoreMBA/WPFCoreBA.cs b/src/ext/Bal/test/examples/WPFCoreMBA/WPFCoreBA.cs new file mode 100644 index 00000000..d50be813 --- /dev/null +++ b/src/ext/Bal/test/examples/WPFCoreMBA/WPFCoreBA.cs @@ -0,0 +1,42 @@ +// 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. + +namespace Example.WPFCoreMBA +{ + using System.Windows.Threading; + using WixToolset.Mba.Core; + + public class WPFCoreBA : BootstrapperApplication + { + public WPFCoreBA(IEngine engine) + : base(engine) + { + } + + public Dispatcher BADispatcher { get; private set; } + + protected override void Run() + { + this.BADispatcher = Dispatcher.CurrentDispatcher; + var window = new MainWindow(); + window.Closed += (s, e) => this.BADispatcher.InvokeShutdown(); + //window.Show(); + //Dispatcher.Run(); + //this.engine.Quit(0); + } + + protected override void OnStartup(StartupEventArgs args) + { + base.OnStartup(args); + + this.engine.Log(LogLevel.Standard, nameof(WPFCoreBA)); + } + + protected override void OnShutdown(ShutdownEventArgs args) + { + base.OnShutdown(args); + + var message = "Shutdown," + args.Action.ToString() + "," + args.HResult.ToString(); + this.engine.Log(LogLevel.Standard, message); + } + } +} diff --git a/src/ext/Bal/test/examples/WPFCoreMBA/WPFCoreBAFactory.cs b/src/ext/Bal/test/examples/WPFCoreMBA/WPFCoreBAFactory.cs new file mode 100644 index 00000000..a3ccdf9f --- /dev/null +++ b/src/ext/Bal/test/examples/WPFCoreMBA/WPFCoreBAFactory.cs @@ -0,0 +1,22 @@ +// 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. + +[assembly: WixToolset.Mba.Core.BootstrapperApplicationFactory(typeof(Example.WPFCoreMBA.WPFCoreBAFactory))] +namespace Example.WPFCoreMBA +{ + using WixToolset.Mba.Core; + + public class WPFCoreBAFactory : BaseBootstrapperApplicationFactory + { + private static int loadCount = 0; + + protected override IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand) + { + if (loadCount > 0) + { + engine.Log(LogLevel.Standard, $"Reloaded {loadCount} time(s)"); + } + ++loadCount; + return new WPFCoreBA(engine); + } + } +} diff --git a/src/ext/Bal/test/examples/Wix.Build.props b/src/ext/Bal/test/examples/Wix.Build.props new file mode 100644 index 00000000..aad94bb6 --- /dev/null +++ b/src/ext/Bal/test/examples/Wix.Build.props @@ -0,0 +1,10 @@ + + + + + Bundle + .exe + -generate payloadgroup + $(OutputPath)examples\ + + diff --git a/src/ext/Bal/test/examples/Wix.Build.targets b/src/ext/Bal/test/examples/Wix.Build.targets new file mode 100644 index 00000000..7e6fe9f2 --- /dev/null +++ b/src/ext/Bal/test/examples/Wix.Build.targets @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/ext/Bal/test/examples/examples.proj b/src/ext/Bal/test/examples/examples.proj new file mode 100644 index 00000000..08cb7511 --- /dev/null +++ b/src/ext/Bal/test/examples/examples.proj @@ -0,0 +1,50 @@ + + + + + + + + + EarliestCoreMBA\Example.EarliestCoreMBA.csproj + FullFramework2MBA\Example.FullFramework2MBA.csproj + FullFramework4MBA\Example.FullFramework4MBA.csproj + LatestCoreMBA\Example.LatestCoreMBA.csproj + WPFCoreMBA\Example.WPFCoreMBA.csproj + $(OutputPath)examples\publish\ + + + + + $(MBAPublishPath)Example.EarliestCoreMBA + + + $(MBAPublishPath)Example.LatestCoreMBA + + + $(MBAPublishPath)Example.WPFCoreMBA + true + true + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- cgit v1.2.3-55-g6feb