diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2019-12-22 10:31:33 +1100 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2019-12-22 13:19:29 +1000 |
commit | 24379873f589cff33965f1104041f61c0c4503e0 (patch) | |
tree | b50fb0270d2de706cb6f3a4dea0af77ce2cae9e1 /src | |
parent | f3c383c2412e376353d64a8b744184fa1cee1c6e (diff) | |
download | wix-24379873f589cff33965f1104041f61c0c4503e0.tar.gz wix-24379873f589cff33965f1104041f61c0c4503e0.tar.bz2 wix-24379873f589cff33965f1104041f61c0c4503e0.zip |
Move the responsibility of wrapping the binary interfaces from mbahost to the new mbanative dll of WixToolset.Mba.Core.
Diffstat (limited to 'src')
19 files changed, 381 insertions, 22 deletions
diff --git a/src/WixToolset.Mba.Core/BalUtil.cs b/src/WixToolset.Mba.Core/BalUtil.cs new file mode 100644 index 00000000..f478eca4 --- /dev/null +++ b/src/WixToolset.Mba.Core/BalUtil.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 | namespace WixToolset.Mba.Core | ||
4 | { | ||
5 | using System; | ||
6 | using System.Runtime.InteropServices; | ||
7 | |||
8 | internal static class BalUtil | ||
9 | { | ||
10 | [DllImport("mbanative.dll", ExactSpelling = true, PreserveSig = false)] | ||
11 | internal static extern IBootstrapperEngine InitializeFromCreateArgs( | ||
12 | IntPtr pArgs, | ||
13 | ref Command pCommand | ||
14 | ); | ||
15 | |||
16 | [DllImport("mbanative.dll", ExactSpelling = true)] | ||
17 | internal static extern void StoreBAInCreateResults( | ||
18 | IntPtr pResults, | ||
19 | [MarshalAs(UnmanagedType.Interface)] IBootstrapperApplication pBA | ||
20 | ); | ||
21 | } | ||
22 | } | ||
diff --git a/src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs b/src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs index 20151b71..264733ac 100644 --- a/src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs +++ b/src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs | |||
@@ -2,15 +2,35 @@ | |||
2 | 2 | ||
3 | namespace WixToolset.Mba.Core | 3 | namespace WixToolset.Mba.Core |
4 | { | 4 | { |
5 | using System; | ||
6 | using System.Runtime.InteropServices; | ||
7 | |||
5 | public abstract class BaseBootstrapperApplicationFactory : IBootstrapperApplicationFactory | 8 | public abstract class BaseBootstrapperApplicationFactory : IBootstrapperApplicationFactory |
6 | { | 9 | { |
7 | public IBootstrapperApplication Create(IBootstrapperEngine pEngine, ref Command command) | 10 | public void Create(IntPtr pArgs, IntPtr pResults) |
8 | { | 11 | { |
9 | IEngine engine = new Engine(pEngine); | 12 | InitializeFromCreateArgs(pArgs, out var engine, out var bootstrapperCommand); |
10 | IBootstrapperCommand bootstrapperCommand = command.GetBootstrapperCommand(); | 13 | |
11 | return this.Create(engine, bootstrapperCommand); | 14 | var ba = this.Create(engine, bootstrapperCommand); |
15 | StoreBAInCreateResults(pResults, ba); | ||
12 | } | 16 | } |
13 | 17 | ||
14 | protected abstract IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand); | 18 | protected abstract IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand); |
19 | |||
20 | public static void InitializeFromCreateArgs(IntPtr pArgs, out IEngine engine, out IBootstrapperCommand bootstrapperCommand) | ||
21 | { | ||
22 | Command pCommand = new Command | ||
23 | { | ||
24 | cbSize = Marshal.SizeOf(typeof(Command)) | ||
25 | }; | ||
26 | var pEngine = BalUtil.InitializeFromCreateArgs(pArgs, ref pCommand); | ||
27 | engine = new Engine(pEngine); | ||
28 | bootstrapperCommand = pCommand.GetBootstrapperCommand(); | ||
29 | } | ||
30 | |||
31 | public static void StoreBAInCreateResults(IntPtr pResults, IBootstrapperApplication ba) | ||
32 | { | ||
33 | BalUtil.StoreBAInCreateResults(pResults, ba); | ||
34 | } | ||
15 | } | 35 | } |
16 | } | 36 | } |
diff --git a/src/WixToolset.Mba.Core/BootstrapperApplicationFactory.cs b/src/WixToolset.Mba.Core/BootstrapperApplicationFactory.cs index 968c6336..55f0e83b 100644 --- a/src/WixToolset.Mba.Core/BootstrapperApplicationFactory.cs +++ b/src/WixToolset.Mba.Core/BootstrapperApplicationFactory.cs | |||
@@ -8,7 +8,7 @@ namespace WixToolset.Mba.Core | |||
8 | using System.Runtime.InteropServices; | 8 | using System.Runtime.InteropServices; |
9 | 9 | ||
10 | /// <summary> | 10 | /// <summary> |
11 | /// Entry point for the MBA host to create and return the IBootstrapperApplication implementation to the engine. | 11 | /// Entry point for the MBA host to create and return the BA to the engine. |
12 | /// </summary> | 12 | /// </summary> |
13 | [ClassInterface(ClassInterfaceType.None)] | 13 | [ClassInterface(ClassInterfaceType.None)] |
14 | public sealed class BootstrapperApplicationFactory : MarshalByRefObject, IBootstrapperApplicationFactory | 14 | public sealed class BootstrapperApplicationFactory : MarshalByRefObject, IBootstrapperApplicationFactory |
@@ -21,14 +21,13 @@ namespace WixToolset.Mba.Core | |||
21 | } | 21 | } |
22 | 22 | ||
23 | /// <summary> | 23 | /// <summary> |
24 | /// Loads the bootstrapper application assembly and creates an instance of the IBootstrapperApplication. | 24 | /// Loads the bootstrapper application assembly and calls its IBootstrapperApplicationFactory.Create method. |
25 | /// </summary> | 25 | /// </summary> |
26 | /// <param name="pEngine">IBootstrapperEngine provided for the bootstrapper application.</param> | 26 | /// <param name="pArgs">Pointer to BOOTSTRAPPER_CREATE_ARGS struct.</param> |
27 | /// <param name="command">Command line for the bootstrapper application.</param> | 27 | /// <param name="pResults">Pointer to BOOTSTRAPPER_CREATE_RESULTS struct.</param> |
28 | /// <returns>Bootstrapper application via <see cref="IBootstrapperApplication"/> interface.</returns> | ||
29 | /// <exception cref="MissingAttributeException">The bootstrapper application assembly | 28 | /// <exception cref="MissingAttributeException">The bootstrapper application assembly |
30 | /// does not define the <see cref="BootstrapperApplicationFactoryAttribute"/>.</exception> | 29 | /// does not define the <see cref="BootstrapperApplicationFactoryAttribute"/>.</exception> |
31 | public IBootstrapperApplication Create(IBootstrapperEngine pEngine, ref Command command) | 30 | public void Create(IntPtr pArgs, IntPtr pResults) |
32 | { | 31 | { |
33 | // Get the wix.boostrapper section group to get the name of the bootstrapper application assembly to host. | 32 | // Get the wix.boostrapper section group to get the name of the bootstrapper application assembly to host. |
34 | var section = ConfigurationManager.GetSection("wix.bootstrapper/host") as HostSection; | 33 | var section = ConfigurationManager.GetSection("wix.bootstrapper/host") as HostSection; |
@@ -45,8 +44,7 @@ namespace WixToolset.Mba.Core | |||
45 | throw new InvalidBootstrapperApplicationFactoryException(); | 44 | throw new InvalidBootstrapperApplicationFactoryException(); |
46 | } | 45 | } |
47 | 46 | ||
48 | var ba = baFactory.Create(pEngine, ref command); | 47 | baFactory.Create(pArgs, pResults); |
49 | return ba; | ||
50 | } | 48 | } |
51 | 49 | ||
52 | /// <summary> | 50 | /// <summary> |
diff --git a/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs b/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs index f5d4c705..700f0888 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs | |||
@@ -12,9 +12,9 @@ namespace WixToolset.Mba.Core | |||
12 | [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")] | 12 | [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")] |
13 | public interface IBootstrapperApplicationFactory | 13 | public interface IBootstrapperApplicationFactory |
14 | { | 14 | { |
15 | IBootstrapperApplication Create( | 15 | void Create( |
16 | [MarshalAs(UnmanagedType.Interface)] IBootstrapperEngine pEngine, | 16 | IntPtr pArgs, |
17 | ref Command command | 17 | IntPtr pResults |
18 | ); | 18 | ); |
19 | } | 19 | } |
20 | 20 | ||
@@ -23,6 +23,7 @@ namespace WixToolset.Mba.Core | |||
23 | [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")] | 23 | [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")] |
24 | public struct Command | 24 | public struct Command |
25 | { | 25 | { |
26 | [MarshalAs(UnmanagedType.I4)] internal int cbSize; | ||
26 | [MarshalAs(UnmanagedType.U4)] private readonly LaunchAction action; | 27 | [MarshalAs(UnmanagedType.U4)] private readonly LaunchAction action; |
27 | [MarshalAs(UnmanagedType.U4)] private readonly Display display; | 28 | [MarshalAs(UnmanagedType.U4)] private readonly Display display; |
28 | [MarshalAs(UnmanagedType.U4)] private readonly Restart restart; | 29 | [MarshalAs(UnmanagedType.U4)] private readonly Restart restart; |
@@ -49,4 +50,25 @@ namespace WixToolset.Mba.Core | |||
49 | this.wzLayoutDirectory); | 50 | this.wzLayoutDirectory); |
50 | } | 51 | } |
51 | } | 52 | } |
53 | |||
54 | [Serializable] | ||
55 | [StructLayout(LayoutKind.Sequential)] | ||
56 | [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")] | ||
57 | public struct BootstrapperCreateArgs | ||
58 | { | ||
59 | [MarshalAs(UnmanagedType.I4)] public readonly int cbSize; | ||
60 | [MarshalAs(UnmanagedType.I8)] public readonly long qwEngineAPIVersion; | ||
61 | public readonly IntPtr pfnBootstrapperEngineProc; | ||
62 | public readonly IntPtr pvBootstrapperEngineProcContext; | ||
63 | public readonly IntPtr pCommand; | ||
64 | |||
65 | public BootstrapperCreateArgs(long version, IntPtr pEngineProc, IntPtr pEngineContext, IntPtr pCommand) | ||
66 | { | ||
67 | this.cbSize = Marshal.SizeOf(typeof(BootstrapperCreateArgs)); | ||
68 | this.qwEngineAPIVersion = version; | ||
69 | this.pfnBootstrapperEngineProc = pEngineProc; | ||
70 | this.pvBootstrapperEngineProcContext = pEngineContext; | ||
71 | this.pCommand = pCommand; | ||
72 | } | ||
73 | } | ||
52 | } | 74 | } |
diff --git a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj index 05d042c3..4b14a545 100644 --- a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj +++ b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj | |||
@@ -23,6 +23,7 @@ | |||
23 | <DefineConstants>$(DefineConstants);TRACE</DefineConstants> | 23 | <DefineConstants>$(DefineConstants);TRACE</DefineConstants> |
24 | </PropertyGroup> | 24 | </PropertyGroup> |
25 | <ItemGroup> | 25 | <ItemGroup> |
26 | <Compile Include="BalUtil.cs" /> | ||
26 | <Compile Include="BaseBootstrapperApplicationFactory.cs" /> | 27 | <Compile Include="BaseBootstrapperApplicationFactory.cs" /> |
27 | <Compile Include="BootstrapperApplication.cs" /> | 28 | <Compile Include="BootstrapperApplication.cs" /> |
28 | <Compile Include="BootstrapperApplicationData.cs" /> | 29 | <Compile Include="BootstrapperApplicationData.cs" /> |
diff --git a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec index 04eee9ec..bbac204f 100644 --- a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec +++ b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec | |||
@@ -7,7 +7,7 @@ | |||
7 | <owners>WiX Toolset Team</owners> | 7 | <owners>WiX Toolset Team</owners> |
8 | <!-- <license type="expression">MS-RL</license> --> | 8 | <!-- <license type="expression">MS-RL</license> --> |
9 | <licenseUrl>https://licenses.nuget.org/MS-RL</licenseUrl> | 9 | <licenseUrl>https://licenses.nuget.org/MS-RL</licenseUrl> |
10 | <projectUrl>https://github.com/wixtoolset/BootstrapperCore</projectUrl> | 10 | <projectUrl>https://github.com/wixtoolset/balutil</projectUrl> |
11 | <requireLicenseAcceptance>false</requireLicenseAcceptance> | 11 | <requireLicenseAcceptance>false</requireLicenseAcceptance> |
12 | <description>$description$</description> | 12 | <description>$description$</description> |
13 | <copyright>$copyright$</copyright> | 13 | <copyright>$copyright$</copyright> |
@@ -15,6 +15,8 @@ | |||
15 | 15 | ||
16 | <files> | 16 | <files> |
17 | <file src="..\..\build\$configuration$\$id$.config" target="samples" /> | 17 | <file src="..\..\build\$configuration$\$id$.config" target="samples" /> |
18 | <file src="build\net20\$id$.props" target="build\net20" /> | ||
19 | <file src="..\..\build\$configuration$\v141_xp\x86\mbanative.dll" target="build\net20\x86" /> | ||
18 | <file src="..\..\build\$configuration$\$id$.h" target="build\native\include" /> | 20 | <file src="..\..\build\$configuration$\$id$.h" target="build\native\include" /> |
19 | <file src="..\..\build\$configuration$\$id$.dll" target="lib\net20" /> | 21 | <file src="..\..\build\$configuration$\$id$.dll" target="lib\net20" /> |
20 | </files> | 22 | </files> |
diff --git a/src/WixToolset.Mba.Core/build/net20/WixToolset.Mba.Core.props b/src/WixToolset.Mba.Core/build/net20/WixToolset.Mba.Core.props new file mode 100644 index 00000000..c0018e0d --- /dev/null +++ b/src/WixToolset.Mba.Core/build/net20/WixToolset.Mba.Core.props | |||
@@ -0,0 +1,11 @@ | |||
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 | <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
5 | <PropertyGroup> | ||
6 | <WixToolsetMbaNativePath Condition=" '$(WixToolsetMbaNativePath)' == '' ">$(MSBuildThisFileDirectory)x86\mbanative.dll</WixToolsetMbaNativePath> | ||
7 | </PropertyGroup> | ||
8 | <ItemGroup> | ||
9 | <Content Include="$(WixToolsetMbaNativePath)" CopyToOutputDirectory="Always" /> | ||
10 | </ItemGroup> | ||
11 | </Project> | ||
diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj index 42aa909e..9d7dc0a5 100644 --- a/src/balutil/balutil.vcxproj +++ b/src/balutil/balutil.vcxproj | |||
@@ -2,7 +2,7 @@ | |||
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. --> | 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 | 3 | ||
4 | <Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | 4 | <Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
5 | <Import Project="..\..\packages\WixToolset.BootstrapperCore.Native.4.0.8\build\WixToolset.BootstrapperCore.Native.props" Condition="Exists('..\..\packages\WixToolset.BootstrapperCore.Native.4.0.8\build\WixToolset.BootstrapperCore.Native.props')" /> | 5 | <Import Project="..\..\packages\WixToolset.BootstrapperCore.Native.4.0.10\build\WixToolset.BootstrapperCore.Native.props" Condition="Exists('..\..\packages\WixToolset.BootstrapperCore.Native.4.0.10\build\WixToolset.BootstrapperCore.Native.props')" /> |
6 | <Import Project="..\..\packages\WixToolset.DUtil.4.0.18\build\WixToolset.DUtil.props" Condition="Exists('..\..\packages\WixToolset.DUtil.4.0.18\build\WixToolset.DUtil.props')" /> | 6 | <Import Project="..\..\packages\WixToolset.DUtil.4.0.18\build\WixToolset.DUtil.props" Condition="Exists('..\..\packages\WixToolset.DUtil.4.0.18\build\WixToolset.DUtil.props')" /> |
7 | 7 | ||
8 | <ItemGroup Label="ProjectConfigurations"> | 8 | <ItemGroup Label="ProjectConfigurations"> |
@@ -70,7 +70,9 @@ | |||
70 | <ClInclude Include="inc\balretry.h" /> | 70 | <ClInclude Include="inc\balretry.h" /> |
71 | <ClInclude Include="inc\balutil.h" /> | 71 | <ClInclude Include="inc\balutil.h" /> |
72 | <ClInclude Include="inc\IBAFunctions.h" /> | 72 | <ClInclude Include="inc\IBAFunctions.h" /> |
73 | <ClInclude Include="inc\IBootstrapperApplication.h" /> | ||
73 | <ClInclude Include="inc\IBootstrapperApplicationFactory.h" /> | 74 | <ClInclude Include="inc\IBootstrapperApplicationFactory.h" /> |
75 | <ClInclude Include="inc\IBootstrapperEngine.h" /> | ||
74 | <ClInclude Include="precomp.h" /> | 76 | <ClInclude Include="precomp.h" /> |
75 | </ItemGroup> | 77 | </ItemGroup> |
76 | 78 | ||
@@ -88,7 +90,7 @@ | |||
88 | <PropertyGroup> | 90 | <PropertyGroup> |
89 | <ErrorText>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}.</ErrorText> | 91 | <ErrorText>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}.</ErrorText> |
90 | </PropertyGroup> | 92 | </PropertyGroup> |
91 | <Error Condition="!Exists('..\..\packages\WixToolset.BootstrapperCore.Native.4.0.8\build\WixToolset.BootstrapperCore.Native.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.BootstrapperCore.Native.4.0.8\build\WixToolset.BootstrapperCore.Native.props'))" /> | 93 | <Error Condition="!Exists('..\..\packages\WixToolset.BootstrapperCore.Native.4.0.10\build\WixToolset.BootstrapperCore.Native.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.BootstrapperCore.Native.4.0.10\build\WixToolset.BootstrapperCore.Native.props'))" /> |
92 | <Error Condition="!Exists('..\..\packages\WixToolset.DUtil.4.0.18\build\WixToolset.DUtil.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.DUtil.4.0.18\build\WixToolset.DUtil.props'))" /> | 94 | <Error Condition="!Exists('..\..\packages\WixToolset.DUtil.4.0.18\build\WixToolset.DUtil.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.DUtil.4.0.18\build\WixToolset.DUtil.props'))" /> |
93 | <Error Condition="!Exists('..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets'))" /> | 95 | <Error Condition="!Exists('..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets'))" /> |
94 | </Target> | 96 | </Target> |
diff --git a/src/balutil/inc/IBootstrapperApplicationFactory.h b/src/balutil/inc/IBootstrapperApplicationFactory.h index e29c23bc..fd603e50 100644 --- a/src/balutil/inc/IBootstrapperApplicationFactory.h +++ b/src/balutil/inc/IBootstrapperApplicationFactory.h | |||
@@ -7,8 +7,7 @@ | |||
7 | DECLARE_INTERFACE_IID_(IBootstrapperApplicationFactory, IUnknown, "2965A12F-AC7B-43A0-85DF-E4B2168478A4") | 7 | DECLARE_INTERFACE_IID_(IBootstrapperApplicationFactory, IUnknown, "2965A12F-AC7B-43A0-85DF-E4B2168478A4") |
8 | { | 8 | { |
9 | STDMETHOD(Create)( | 9 | STDMETHOD(Create)( |
10 | __in IBootstrapperEngine* pEngine, | 10 | __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, |
11 | __in const BOOTSTRAPPER_COMMAND *pCommand, | 11 | __inout BOOTSTRAPPER_CREATE_RESULTS *pResults |
12 | __out IBootstrapperApplication **ppApplication | ||
13 | ); | 12 | ); |
14 | }; | 13 | }; |
diff --git a/src/balutil/packages.config b/src/balutil/packages.config index 769c5a6e..d747d6a9 100644 --- a/src/balutil/packages.config +++ b/src/balutil/packages.config | |||
@@ -1,6 +1,6 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <packages> | 2 | <packages> |
3 | <package id="Nerdbank.GitVersioning" version="2.1.65" targetFramework="native" developmentDependency="true" /> | 3 | <package id="Nerdbank.GitVersioning" version="2.1.65" targetFramework="native" developmentDependency="true" /> |
4 | <package id="WixToolset.BootstrapperCore.Native" version="4.0.8" targetFramework="native" /> | 4 | <package id="WixToolset.BootstrapperCore.Native" version="4.0.10" targetFramework="native" /> |
5 | <package id="WixToolset.DUtil" version="4.0.18" targetFramework="native" /> | 5 | <package id="WixToolset.DUtil" version="4.0.18" targetFramework="native" /> |
6 | </packages> \ No newline at end of file | 6 | </packages> \ No newline at end of file |
diff --git a/src/mbanative/mbanative.cpp b/src/mbanative/mbanative.cpp new file mode 100644 index 00000000..745b50e7 --- /dev/null +++ b/src/mbanative/mbanative.cpp | |||
@@ -0,0 +1,29 @@ | |||
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 | #include "precomp.h" | ||
4 | #include "BalBaseBootstrapperApplicationProc.h" | ||
5 | |||
6 | extern "C" HRESULT WINAPI InitializeFromCreateArgs( | ||
7 | __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, | ||
8 | __inout BOOTSTRAPPER_COMMAND* pCommand, | ||
9 | __out IBootstrapperEngine** ppEngine | ||
10 | ) | ||
11 | { | ||
12 | HRESULT hr = S_OK; | ||
13 | |||
14 | hr = BalInitializeFromCreateArgs(pArgs, ppEngine); | ||
15 | ExitOnFailure(hr, "Failed to initialize Bal."); | ||
16 | |||
17 | memcpy_s(pCommand, pCommand->cbSize, pArgs->pCommand, pArgs->pCommand->cbSize); | ||
18 | LExit: | ||
19 | return hr; | ||
20 | } | ||
21 | |||
22 | extern "C" void WINAPI StoreBAInCreateResults( | ||
23 | __inout BOOTSTRAPPER_CREATE_RESULTS* pResults, | ||
24 | __in IBootstrapperApplication* pBA | ||
25 | ) | ||
26 | { | ||
27 | pResults->pfnBootstrapperApplicationProc = BalBaseBootstrapperApplicationProc; | ||
28 | pResults->pvBootstrapperApplicationProcContext = pBA; | ||
29 | } | ||
diff --git a/src/mbanative/mbanative.def b/src/mbanative/mbanative.def new file mode 100644 index 00000000..bd366ac7 --- /dev/null +++ b/src/mbanative/mbanative.def | |||
@@ -0,0 +1,6 @@ | |||
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 | EXPORTS | ||
5 | InitializeFromCreateArgs | ||
6 | StoreBAInCreateResults | ||
diff --git a/src/mbanative/mbanative.vcxproj b/src/mbanative/mbanative.vcxproj new file mode 100644 index 00000000..5ec21f74 --- /dev/null +++ b/src/mbanative/mbanative.vcxproj | |||
@@ -0,0 +1,76 @@ | |||
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 | <Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
5 | <Import Project="..\..\packages\WixToolset.BootstrapperCore.Native.4.0.10\build\WixToolset.BootstrapperCore.Native.props" Condition="Exists('..\..\packages\WixToolset.BootstrapperCore.Native.4.0.10\build\WixToolset.BootstrapperCore.Native.props')" /> | ||
6 | <Import Project="..\..\packages\WixToolset.DUtil.4.0.18\build\WixToolset.DUtil.props" Condition="Exists('..\..\packages\WixToolset.DUtil.4.0.18\build\WixToolset.DUtil.props')" /> | ||
7 | |||
8 | <ItemGroup Label="ProjectConfigurations"> | ||
9 | <ProjectConfiguration Include="Debug|Win32"> | ||
10 | <Configuration>Debug</Configuration> | ||
11 | <Platform>Win32</Platform> | ||
12 | </ProjectConfiguration> | ||
13 | <ProjectConfiguration Include="Release|Win32"> | ||
14 | <Configuration>Release</Configuration> | ||
15 | <Platform>Win32</Platform> | ||
16 | </ProjectConfiguration> | ||
17 | <ProjectConfiguration Include="Debug|x64"> | ||
18 | <Configuration>Debug</Configuration> | ||
19 | <Platform>x64</Platform> | ||
20 | </ProjectConfiguration> | ||
21 | <ProjectConfiguration Include="Release|x64"> | ||
22 | <Configuration>Release</Configuration> | ||
23 | <Platform>x64</Platform> | ||
24 | </ProjectConfiguration> | ||
25 | </ItemGroup> | ||
26 | |||
27 | <PropertyGroup Label="Globals"> | ||
28 | <ProjectGuid>{665E0441-17F9-4105-B202-EDF274657F6E}</ProjectGuid> | ||
29 | <ConfigurationType>DynamicLibrary</ConfigurationType> | ||
30 | <PlatformToolset>v141</PlatformToolset> | ||
31 | <CharacterSet>Unicode</CharacterSet> | ||
32 | <TargetName>mbanative</TargetName> | ||
33 | <ProjectModuleDefinitionFile>mbanative.def</ProjectModuleDefinitionFile> | ||
34 | </PropertyGroup> | ||
35 | |||
36 | <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
37 | <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
38 | <Import Project="..\NativeMultiTargeting.Build.props" /> | ||
39 | |||
40 | <PropertyGroup> | ||
41 | <ProjectAdditionalIncludeDirectories>..\balutil\inc</ProjectAdditionalIncludeDirectories> | ||
42 | <ProjectAdditionalLinkLibraries>balutil.lib</ProjectAdditionalLinkLibraries> | ||
43 | </PropertyGroup> | ||
44 | |||
45 | <ItemGroup> | ||
46 | <ClCompile Include="mbanative.cpp" /> | ||
47 | <ClCompile Include="precomp.cpp"> | ||
48 | <PrecompiledHeader>Create</PrecompiledHeader> | ||
49 | </ClCompile> | ||
50 | </ItemGroup> | ||
51 | <ItemGroup> | ||
52 | <ClInclude Include="precomp.h" /> | ||
53 | </ItemGroup> | ||
54 | <ItemGroup> | ||
55 | <None Include="mbanative.def" /> | ||
56 | </ItemGroup> | ||
57 | |||
58 | <ItemGroup> | ||
59 | <None Include="packages.config" /> | ||
60 | </ItemGroup> | ||
61 | |||
62 | <ItemGroup> | ||
63 | <ProjectReference Include="..\balutil\balutil.vcxproj" /> | ||
64 | </ItemGroup> | ||
65 | |||
66 | <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
67 | <Import Project="..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets" Condition="Exists('..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets')" /> | ||
68 | <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> | ||
69 | <PropertyGroup> | ||
70 | <ErrorText>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}.</ErrorText> | ||
71 | </PropertyGroup> | ||
72 | <Error Condition="!Exists('..\..\packages\WixToolset.BootstrapperCore.Native.4.0.10\build\WixToolset.BootstrapperCore.Native.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.BootstrapperCore.Native.4.0.10\build\WixToolset.BootstrapperCore.Native.props'))" /> | ||
73 | <Error Condition="!Exists('..\..\packages\WixToolset.DUtil.4.0.18\build\WixToolset.DUtil.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.DUtil.4.0.18\build\WixToolset.DUtil.props'))" /> | ||
74 | <Error Condition="!Exists('..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets'))" /> | ||
75 | </Target> | ||
76 | </Project> | ||
diff --git a/src/mbanative/packages.config b/src/mbanative/packages.config new file mode 100644 index 00000000..d37b6def --- /dev/null +++ b/src/mbanative/packages.config | |||
@@ -0,0 +1,6 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <packages> | ||
3 | <package id="Nerdbank.GitVersioning" version="2.1.65" targetFramework="native" developmentDependency="true" /> | ||
4 | <package id="WixToolset.BootstrapperCore.Native" version="4.0.10" targetFramework="native" /> | ||
5 | <package id="WixToolset.DUtil" version="4.0.18" targetFramework="native" /> | ||
6 | </packages> \ No newline at end of file | ||
diff --git a/src/mbanative/precomp.cpp b/src/mbanative/precomp.cpp new file mode 100644 index 00000000..37664a1c --- /dev/null +++ b/src/mbanative/precomp.cpp | |||
@@ -0,0 +1,3 @@ | |||
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 | #include "precomp.h" | ||
diff --git a/src/mbanative/precomp.h b/src/mbanative/precomp.h new file mode 100644 index 00000000..54d8cb08 --- /dev/null +++ b/src/mbanative/precomp.h | |||
@@ -0,0 +1,15 @@ | |||
1 | #pragma once | ||
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 | #include <windows.h> | ||
6 | #include <msiquery.h> | ||
7 | |||
8 | #include <dutil.h> | ||
9 | |||
10 | #include "BootstrapperEngine.h" | ||
11 | #include "BootstrapperApplication.h" | ||
12 | #include "IBootstrapperEngine.h" | ||
13 | #include "IBootstrapperApplication.h" | ||
14 | |||
15 | #include "balutil.h" | ||
diff --git a/src/test/WixToolsetTest.Mba.Core/BaseBootstrapperApplicationFactoryFixture.cs b/src/test/WixToolsetTest.Mba.Core/BaseBootstrapperApplicationFactoryFixture.cs new file mode 100644 index 00000000..12483ddf --- /dev/null +++ b/src/test/WixToolsetTest.Mba.Core/BaseBootstrapperApplicationFactoryFixture.cs | |||
@@ -0,0 +1,113 @@ | |||
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.Util | ||
4 | { | ||
5 | using System; | ||
6 | using System.Runtime.InteropServices; | ||
7 | using WixToolset.Mba.Core; | ||
8 | using Xunit; | ||
9 | |||
10 | public class BaseBootstrapperApplicationFactoryFixture | ||
11 | { | ||
12 | [Fact] | ||
13 | public void CanCreateBA() | ||
14 | { | ||
15 | var command = new TestCommand | ||
16 | { | ||
17 | action = LaunchAction.Install, | ||
18 | cbSize = Marshal.SizeOf(typeof(TestCommand)), | ||
19 | display = Display.Full, | ||
20 | wzCommandLine = "this \"is a\" test", | ||
21 | }; | ||
22 | var pCommand = Marshal.AllocHGlobal(command.cbSize); | ||
23 | try | ||
24 | { | ||
25 | Marshal.StructureToPtr(command, pCommand, false); | ||
26 | var createArgs = new BootstrapperCreateArgs(0, IntPtr.Zero, IntPtr.Zero, pCommand); | ||
27 | var pArgs = Marshal.AllocHGlobal(createArgs.cbSize); | ||
28 | try | ||
29 | { | ||
30 | Marshal.StructureToPtr(createArgs, pArgs, false); | ||
31 | var createResults = new TestCreateResults | ||
32 | { | ||
33 | cbSize = Marshal.SizeOf<TestCreateResults>(), | ||
34 | }; | ||
35 | var pResults = Marshal.AllocHGlobal(createResults.cbSize); | ||
36 | try | ||
37 | { | ||
38 | var baFactory = new TestBAFactory(); | ||
39 | baFactory.Create(pArgs, pResults); | ||
40 | |||
41 | createResults = Marshal.PtrToStructure<TestCreateResults>(pResults); | ||
42 | Assert.Equal(baFactory.BA, createResults.pBA); | ||
43 | Assert.Equal(baFactory.BA.Command.Action, command.action); | ||
44 | Assert.Equal(baFactory.BA.Command.Display, command.display); | ||
45 | Assert.Equal(baFactory.BA.Command.CommandLineArgs, new string[] { "this", "is a", "test" }); | ||
46 | } | ||
47 | finally | ||
48 | { | ||
49 | Marshal.FreeHGlobal(pResults); | ||
50 | } | ||
51 | } | ||
52 | finally | ||
53 | { | ||
54 | Marshal.FreeHGlobal(pArgs); | ||
55 | } | ||
56 | } | ||
57 | finally | ||
58 | { | ||
59 | Marshal.FreeHGlobal(pCommand); | ||
60 | } | ||
61 | } | ||
62 | |||
63 | internal class TestBAFactory : BaseBootstrapperApplicationFactory | ||
64 | { | ||
65 | public TestBA BA { get; private set; } | ||
66 | |||
67 | protected override IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand) | ||
68 | { | ||
69 | this.BA = new TestBA(engine, bootstrapperCommand); | ||
70 | return this.BA; | ||
71 | } | ||
72 | } | ||
73 | |||
74 | internal class TestBA : BootstrapperApplication | ||
75 | { | ||
76 | public IBootstrapperCommand Command { get; } | ||
77 | |||
78 | public TestBA(IEngine engine, IBootstrapperCommand command) | ||
79 | : base(engine) | ||
80 | { | ||
81 | this.Command = command; | ||
82 | } | ||
83 | |||
84 | protected override void Run() | ||
85 | { | ||
86 | } | ||
87 | } | ||
88 | |||
89 | [StructLayout(LayoutKind.Sequential)] | ||
90 | public struct TestCommand | ||
91 | { | ||
92 | public int cbSize; | ||
93 | public LaunchAction action; | ||
94 | public Display display; | ||
95 | public Restart restart; | ||
96 | [MarshalAs(UnmanagedType.LPWStr)] public string wzCommandLine; | ||
97 | public int nCmdShow; | ||
98 | public ResumeType resume; | ||
99 | public IntPtr hwndSplashScreen; | ||
100 | public RelationType relation; | ||
101 | [MarshalAs(UnmanagedType.Bool)] public bool passthrough; | ||
102 | [MarshalAs(UnmanagedType.LPWStr)] public string wzLayoutDirectory; | ||
103 | } | ||
104 | |||
105 | [StructLayout(LayoutKind.Sequential)] | ||
106 | public struct TestCreateResults | ||
107 | { | ||
108 | public int cbSize; | ||
109 | public IntPtr pBAProc; | ||
110 | [MarshalAs(UnmanagedType.Interface)] public IBootstrapperApplication pBA; | ||
111 | } | ||
112 | } | ||
113 | } | ||
diff --git a/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj b/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj new file mode 100644 index 00000000..d401d877 --- /dev/null +++ b/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj | |||
@@ -0,0 +1,29 @@ | |||
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 | <Project Sdk="Microsoft.NET.Sdk"> | ||
5 | <PropertyGroup> | ||
6 | <TargetFramework>netcoreapp2.1</TargetFramework> | ||
7 | <IsPackable>false</IsPackable> | ||
8 | <Platforms>AnyCPU;x86;x64</Platforms> | ||
9 | </PropertyGroup> | ||
10 | |||
11 | <PropertyGroup> | ||
12 | <NoWarn>NU1701</NoWarn> | ||
13 | </PropertyGroup> | ||
14 | |||
15 | <ItemGroup> | ||
16 | <ProjectReference Include="..\..\mbanative\mbanative.vcxproj"> | ||
17 | <Project>{665E0441-17F9-4105-B202-EDF274657F6E}</Project> | ||
18 | <OutputItemType>Content</OutputItemType> | ||
19 | <CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
20 | </ProjectReference> | ||
21 | <ProjectReference Include="..\..\WixToolset.Mba.Core\WixToolset.Mba.Core.csproj" /> | ||
22 | </ItemGroup> | ||
23 | |||
24 | <ItemGroup> | ||
25 | <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" /> | ||
26 | <PackageReference Include="xunit" Version="2.4.1" /> | ||
27 | <PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" PrivateAssets="All" /> | ||
28 | </ItemGroup> | ||
29 | </Project> | ||
diff --git a/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.v3.ncrunchproject b/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.v3.ncrunchproject new file mode 100644 index 00000000..7b5b2139 --- /dev/null +++ b/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.v3.ncrunchproject | |||
@@ -0,0 +1,5 @@ | |||
1 | <ProjectConfiguration> | ||
2 | <Settings> | ||
3 | <CopyReferencedAssembliesToWorkspace>True</CopyReferencedAssembliesToWorkspace> | ||
4 | </Settings> | ||
5 | </ProjectConfiguration> \ No newline at end of file | ||