diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2020-04-29 19:28:50 +1000 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2020-04-29 19:53:29 +1000 |
commit | 39e930d9aaff250e0fd5019eeedaa40717a6c6fe (patch) | |
tree | bc0865bc6c9ced1b4a06b408ff60cb83ef73cad3 /src/test/examples | |
parent | f4b14ff16f78435285bb20f16d5d62b902e6ba17 (diff) | |
download | wix-39e930d9aaff250e0fd5019eeedaa40717a6c6fe.tar.gz wix-39e930d9aaff250e0fd5019eeedaa40717a6c6fe.tar.bz2 wix-39e930d9aaff250e0fd5019eeedaa40717a6c6fe.zip |
Add DotNetCoreBootstrapperApplicationHost for an SCD-style .NET Core BA.
Diffstat (limited to 'src/test/examples')
8 files changed, 168 insertions, 1 deletions
diff --git a/src/test/examples/EarliestCoreMBA/EarliestCoreBA.cs b/src/test/examples/EarliestCoreMBA/EarliestCoreBA.cs new file mode 100644 index 00000000..c9291a7f --- /dev/null +++ b/src/test/examples/EarliestCoreMBA/EarliestCoreBA.cs | |||
@@ -0,0 +1,34 @@ | |||
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 Example.EarliestCoreMBA | ||
4 | { | ||
5 | using WixToolset.Mba.Core; | ||
6 | |||
7 | public class EarliestCoreBA : BootstrapperApplication | ||
8 | { | ||
9 | public EarliestCoreBA(IEngine engine) | ||
10 | : base(engine) | ||
11 | { | ||
12 | |||
13 | } | ||
14 | |||
15 | protected override void Run() | ||
16 | { | ||
17 | } | ||
18 | |||
19 | protected override void OnStartup(StartupEventArgs args) | ||
20 | { | ||
21 | base.OnStartup(args); | ||
22 | |||
23 | this.engine.Log(LogLevel.Standard, nameof(EarliestCoreBA)); | ||
24 | } | ||
25 | |||
26 | protected override void OnShutdown(ShutdownEventArgs args) | ||
27 | { | ||
28 | base.OnShutdown(args); | ||
29 | |||
30 | var message = "Shutdown," + args.Action.ToString() + "," + args.HResult.ToString(); | ||
31 | this.engine.Log(LogLevel.Standard, message); | ||
32 | } | ||
33 | } | ||
34 | } | ||
diff --git a/src/test/examples/EarliestCoreMBA/EarliestCoreBAFactory.cs b/src/test/examples/EarliestCoreMBA/EarliestCoreBAFactory.cs new file mode 100644 index 00000000..672e17ee --- /dev/null +++ b/src/test/examples/EarliestCoreMBA/EarliestCoreBAFactory.cs | |||
@@ -0,0 +1,22 @@ | |||
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(Example.EarliestCoreMBA.EarliestCoreBAFactory))] | ||
4 | namespace Example.EarliestCoreMBA | ||
5 | { | ||
6 | using WixToolset.Mba.Core; | ||
7 | |||
8 | public class EarliestCoreBAFactory : 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 EarliestCoreBA(engine); | ||
20 | } | ||
21 | } | ||
22 | } | ||
diff --git a/src/test/examples/EarliestCoreMBA/Example.EarliestCoreMBA.csproj b/src/test/examples/EarliestCoreMBA/Example.EarliestCoreMBA.csproj new file mode 100644 index 00000000..326633ba --- /dev/null +++ b/src/test/examples/EarliestCoreMBA/Example.EarliestCoreMBA.csproj | |||
@@ -0,0 +1,18 @@ | |||
1 | <Project Sdk="Microsoft.NET.Sdk"> | ||
2 | |||
3 | <PropertyGroup> | ||
4 | <TargetFramework>netcoreapp3.0</TargetFramework> | ||
5 | <RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers> | ||
6 | <EnableDynamicLoading>true</EnableDynamicLoading> | ||
7 | <Description>Earliest .NET Core MBA</Description> | ||
8 | </PropertyGroup> | ||
9 | |||
10 | <ItemGroup> | ||
11 | <TrimmerRootAssembly Include="System.Runtime.Loader" /> | ||
12 | </ItemGroup> | ||
13 | |||
14 | <ItemGroup> | ||
15 | <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.65" PrivateAssets="all" /> | ||
16 | <PackageReference Include="WixToolset.Mba.Core" Version="4.0.19" /> | ||
17 | </ItemGroup> | ||
18 | </Project> \ No newline at end of file | ||
diff --git a/src/test/examples/LatestCoreMBA/Example.LatestCoreMBA.csproj b/src/test/examples/LatestCoreMBA/Example.LatestCoreMBA.csproj new file mode 100644 index 00000000..1d325b1b --- /dev/null +++ b/src/test/examples/LatestCoreMBA/Example.LatestCoreMBA.csproj | |||
@@ -0,0 +1,23 @@ | |||
1 | <Project Sdk="Microsoft.NET.Sdk"> | ||
2 | |||
3 | <PropertyGroup> | ||
4 | <TargetFramework>netcoreapp3.1</TargetFramework> | ||
5 | <RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers> | ||
6 | <EnableDynamicLoading>true</EnableDynamicLoading> | ||
7 | <Description>Latest .NET Core MBA</Description> | ||
8 | </PropertyGroup> | ||
9 | |||
10 | <PropertyGroup Condition="'$(PublishTrimmed)'=='true'"> | ||
11 | <PublishReadyToRunShowWarnings>false</PublishReadyToRunShowWarnings> | ||
12 | <PublishReadyToRun>true</PublishReadyToRun> | ||
13 | </PropertyGroup> | ||
14 | |||
15 | <ItemGroup> | ||
16 | <TrimmerRootAssembly Include="System.Runtime.Loader" /> | ||
17 | </ItemGroup> | ||
18 | |||
19 | <ItemGroup> | ||
20 | <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.65" PrivateAssets="all" /> | ||
21 | <PackageReference Include="WixToolset.Mba.Core" Version="4.0.19" /> | ||
22 | </ItemGroup> | ||
23 | </Project> \ No newline at end of file | ||
diff --git a/src/test/examples/LatestCoreMBA/LatestCoreBA.cs b/src/test/examples/LatestCoreMBA/LatestCoreBA.cs new file mode 100644 index 00000000..50386a87 --- /dev/null +++ b/src/test/examples/LatestCoreMBA/LatestCoreBA.cs | |||
@@ -0,0 +1,33 @@ | |||
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 Example.LatestCoreMBA | ||
4 | { | ||
5 | using WixToolset.Mba.Core; | ||
6 | |||
7 | public class LatestCoreBA : BootstrapperApplication | ||
8 | { | ||
9 | public LatestCoreBA(IEngine engine) | ||
10 | : base(engine) | ||
11 | { | ||
12 | } | ||
13 | |||
14 | protected override void Run() | ||
15 | { | ||
16 | } | ||
17 | |||
18 | protected override void OnStartup(StartupEventArgs args) | ||
19 | { | ||
20 | base.OnStartup(args); | ||
21 | |||
22 | this.engine.Log(LogLevel.Standard, nameof(LatestCoreBA)); | ||
23 | } | ||
24 | |||
25 | protected override void OnShutdown(ShutdownEventArgs args) | ||
26 | { | ||
27 | base.OnShutdown(args); | ||
28 | |||
29 | var message = "Shutdown," + args.Action.ToString() + "," + args.HResult.ToString(); | ||
30 | this.engine.Log(LogLevel.Standard, message); | ||
31 | } | ||
32 | } | ||
33 | } | ||
diff --git a/src/test/examples/LatestCoreMBA/LatestCoreBAFactory.cs b/src/test/examples/LatestCoreMBA/LatestCoreBAFactory.cs new file mode 100644 index 00000000..fff3b5c5 --- /dev/null +++ b/src/test/examples/LatestCoreMBA/LatestCoreBAFactory.cs | |||
@@ -0,0 +1,22 @@ | |||
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(Example.LatestCoreMBA.LatestCoreBAFactory))] | ||
4 | namespace Example.LatestCoreMBA | ||
5 | { | ||
6 | using WixToolset.Mba.Core; | ||
7 | |||
8 | public class LatestCoreBAFactory : 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 LatestCoreBA(engine); | ||
20 | } | ||
21 | } | ||
22 | } | ||
diff --git a/src/test/examples/TestEngine/TestEngine.cpp b/src/test/examples/TestEngine/TestEngine.cpp index 203df115..f0811e0a 100644 --- a/src/test/examples/TestEngine/TestEngine.cpp +++ b/src/test/examples/TestEngine/TestEngine.cpp | |||
@@ -35,6 +35,12 @@ HRESULT TestEngine::LoadBA( | |||
35 | 35 | ||
36 | command.cbSize = sizeof(BOOTSTRAPPER_COMMAND); | 36 | command.cbSize = sizeof(BOOTSTRAPPER_COMMAND); |
37 | 37 | ||
38 | hr = PathGetDirectory(wzBAFilePath, &command.wzBootstrapperWorkingFolder); | ||
39 | ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to allocate wzBootstrapperWorkingFolder"); | ||
40 | |||
41 | hr = PathConcat(command.wzBootstrapperWorkingFolder, L"BootstrapperApplicationData.xml", &command.wzBootstrapperApplicationDataPath); | ||
42 | ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to allocate wzBootstrapperApplicationDataPath"); | ||
43 | |||
38 | args.cbSize = sizeof(BOOTSTRAPPER_CREATE_ARGS); | 44 | args.cbSize = sizeof(BOOTSTRAPPER_CREATE_ARGS); |
39 | args.pCommand = &command; | 45 | args.pCommand = &command; |
40 | args.pfnBootstrapperEngineProc = TestEngine::EngineProc; | 46 | args.pfnBootstrapperEngineProc = TestEngine::EngineProc; |
@@ -53,6 +59,9 @@ HRESULT TestEngine::LoadBA( | |||
53 | ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure on BootstrapperApplicationCreate."); | 59 | ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure on BootstrapperApplicationCreate."); |
54 | 60 | ||
55 | LExit: | 61 | LExit: |
62 | ReleaseStr(command.wzBootstrapperApplicationDataPath); | ||
63 | ReleaseStr(command.wzBootstrapperWorkingFolder); | ||
64 | |||
56 | return hr; | 65 | return hr; |
57 | } | 66 | } |
58 | 67 | ||
@@ -92,6 +101,7 @@ HRESULT TestEngine::SendStartupEvent() | |||
92 | void TestEngine::UnloadBA() | 101 | void TestEngine::UnloadBA() |
93 | { | 102 | { |
94 | PFN_BOOTSTRAPPER_APPLICATION_DESTROY pfnDestroy = NULL; | 103 | PFN_BOOTSTRAPPER_APPLICATION_DESTROY pfnDestroy = NULL; |
104 | BOOL fDisableUnloading = m_pCreateResults && m_pCreateResults->fDisableUnloading; | ||
95 | 105 | ||
96 | ReleaseNullMem(m_pCreateResults); | 106 | ReleaseNullMem(m_pCreateResults); |
97 | 107 | ||
@@ -104,7 +114,11 @@ void TestEngine::UnloadBA() | |||
104 | 114 | ||
105 | if (m_hBAModule) | 115 | if (m_hBAModule) |
106 | { | 116 | { |
107 | ::FreeLibrary(m_hBAModule); | 117 | if (!fDisableUnloading) |
118 | { | ||
119 | ::FreeLibrary(m_hBAModule); | ||
120 | } | ||
121 | |||
108 | m_hBAModule = NULL; | 122 | m_hBAModule = NULL; |
109 | } | 123 | } |
110 | } | 124 | } |
diff --git a/src/test/examples/TestEngine/precomp.h b/src/test/examples/TestEngine/precomp.h index 0d2afb06..3fbc7e90 100644 --- a/src/test/examples/TestEngine/precomp.h +++ b/src/test/examples/TestEngine/precomp.h | |||
@@ -9,6 +9,7 @@ | |||
9 | #include "logutil.h" | 9 | #include "logutil.h" |
10 | #include "memutil.h" | 10 | #include "memutil.h" |
11 | #include "pathutil.h" | 11 | #include "pathutil.h" |
12 | #include "strutil.h" | ||
12 | 13 | ||
13 | #include "BootstrapperEngine.h" | 14 | #include "BootstrapperEngine.h" |
14 | #include "BootstrapperApplication.h" | 15 | #include "BootstrapperApplication.h" |