Move the entry point from Mba.Core to Mba.Host.
Sean Hall committed
Dec 22, 2019 at 10:33 UTC
0c3a3b3a7d724a8eb0cb62de05354040d7d1a9f4
9 files changed
+1
-452
src/WixToolset.Mba.Core/BootstrapperApplicationFactory.cs
deleted
-84
@@ -1,84 +0,0 @@
1
-// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
-
3
-namespace WixToolset.Mba.Core
4
-{
5
- using System;
6
- using System.Configuration;
7
- using System.Reflection;
8
- using System.Runtime.InteropServices;
9
-
10
- /// <summary>
11
- /// Entry point for the MBA host to create and return the BA to the engine.
12
- /// </summary>
13
- [ClassInterface(ClassInterfaceType.None)]
14
- public sealed class BootstrapperApplicationFactory : MarshalByRefObject, IBootstrapperApplicationFactory
15
- {
16
- /// <summary>
17
- /// Creates a new instance of the <see cref="BootstrapperApplicationFactory"/> class.
18
- /// </summary>
19
- public BootstrapperApplicationFactory()
20
- {
21
- }
22
-
23
- /// <summary>
24
- /// Loads the bootstrapper application assembly and calls its IBootstrapperApplicationFactory.Create method.
25
- /// </summary>
26
- /// <param name="pArgs">Pointer to BOOTSTRAPPER_CREATE_ARGS struct.</param>
27
- /// <param name="pResults">Pointer to BOOTSTRAPPER_CREATE_RESULTS struct.</param>
28
- /// <exception cref="MissingAttributeException">The bootstrapper application assembly
29
- /// does not define the <see cref="BootstrapperApplicationFactoryAttribute"/>.</exception>
30
- public void Create(IntPtr pArgs, IntPtr pResults)
31
- {
32
- // Get the wix.boostrapper section group to get the name of the bootstrapper application assembly to host.
33
- var section = ConfigurationManager.GetSection("wix.bootstrapper/host") as HostSection;
34
- if (null == section)
35
- {
36
- throw new MissingAttributeException(); // TODO: throw a more specific exception than this.
37
- }
38
-
39
- // Load the BA's IBootstrapperApplicationFactory.
40
- var baFactoryType = BootstrapperApplicationFactory.GetBAFactoryTypeFromAssembly(section.AssemblyName);
41
- var baFactory = (IBootstrapperApplicationFactory)Activator.CreateInstance(baFactoryType);
42
- if (null == baFactory)
43
- {
44
- throw new InvalidBootstrapperApplicationFactoryException();
45
- }
46
-
47
- baFactory.Create(pArgs, pResults);
48
- }
49
-
50
- /// <summary>
51
- /// Locates the <see cref="BootstrapperApplicationFactoryAttribute"/> and returns the specified type.
52
- /// </summary>
53
- /// <param name="assemblyName">The assembly that defines the IBootstrapperApplicationFactory implementation.</param>
54
- /// <returns>The bootstrapper application factory <see cref="Type"/>.</returns>
55
- private static Type GetBAFactoryTypeFromAssembly(string assemblyName)
56
- {
57
- Type baFactoryType = null;
58
-
59
- // Load the requested assembly.
60
- Assembly asm = AppDomain.CurrentDomain.Load(assemblyName);
61
-
62
- // If an assembly was loaded and is not the current assembly, check for the required attribute.
63
- // This is done to avoid using the BootstrapperApplicationFactoryAttribute which we use at build time
64
- // to specify the BootstrapperApplicationFactory assembly in the manifest.
65
- if (!Assembly.GetExecutingAssembly().Equals(asm))
66
- {
67
- // There must be one and only one BootstrapperApplicationFactoryAttribute.
68
- // The attribute prevents multiple declarations already.
69
- var attrs = (BootstrapperApplicationFactoryAttribute[])asm.GetCustomAttributes(typeof(BootstrapperApplicationFactoryAttribute), false);
70
- if (null != attrs)
71
- {
72
- baFactoryType = attrs[0].BootstrapperApplicationFactoryType;
73
- }
74
- }
75
-
76
- if (null == baFactoryType)
77
- {
78
- throw new MissingAttributeException();
79
- }
80
-
81
- return baFactoryType;
82
- }
83
- }
84
-}
src/WixToolset.Mba.Core/BootstrapperSectionGroup.cs
deleted
-29
@@ -1,29 +0,0 @@
1
-// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
-
3
-namespace WixToolset.Mba.Core
4
-{
5
- using System;
6
- using System.Configuration;
7
-
8
- /// <summary>
9
- /// Handler for the wix.bootstrapper configuration section group.
10
- /// </summary>
11
- public class BootstrapperSectionGroup : ConfigurationSectionGroup
12
- {
13
- /// <summary>
14
- /// Creates a new instance of the <see cref="BootstrapperSectionGroup"/> class.
15
- /// </summary>
16
- public BootstrapperSectionGroup()
17
- {
18
- }
19
-
20
- /// <summary>
21
- /// Gets the <see cref="HostSection"/> handler for the mba configuration section.
22
- /// </summary>
23
- [ConfigurationProperty("host")]
24
- public HostSection Host
25
- {
26
- get { return (HostSection)base.Sections["host"]; }
27
- }
28
- }
29
-}
src/WixToolset.Mba.Core/Exceptions.cs
deleted
-145
@@ -1,145 +0,0 @@
1
-// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
-
3
-namespace WixToolset.Mba.Core
4
-{
5
- using System;
6
- using System.Runtime.Serialization;
7
-
8
- /// <summary>
9
- /// Base class for exception returned to the bootstrapper application host.
10
- /// </summary>
11
- [Serializable]
12
- public abstract class BootstrapperException : Exception
13
- {
14
- /// <summary>
15
- /// Creates an instance of the <see cref="BootstrapperException"/> base class with the given HRESULT.
16
- /// </summary>
17
- /// <param name="hr">The HRESULT for the exception that is used by the bootstrapper application host.</param>
18
- public BootstrapperException(int hr)
19
- {
20
- this.HResult = hr;
21
- }
22
-
23
- /// <summary>
24
- /// Initializes a new instance of the <see cref="BootstrapperException"/> class.
25
- /// </summary>
26
- /// <param name="message">Exception message.</param>
27
- public BootstrapperException(string message)
28
- : base(message)
29
- {
30
- }
31
-
32
- /// <summary>
33
- /// Initializes a new instance of the <see cref="BootstrapperException"/> class.
34
- /// </summary>
35
- /// <param name="message">Exception message</param>
36
- /// <param name="innerException">Inner exception associated with this one</param>
37
- public BootstrapperException(string message, Exception innerException)
38
- : base(message, innerException)
39
- {
40
- }
41
-
42
- /// <summary>
43
- /// Initializes a new instance of the <see cref="BootstrapperException"/> class.
44
- /// </summary>
45
- /// <param name="info">Serialization information for this exception</param>
46
- /// <param name="context">Streaming context to serialize to</param>
47
- protected BootstrapperException(SerializationInfo info, StreamingContext context)
48
- : base(info, context)
49
- {
50
- }
51
- }
52
-
53
- /// <summary>
54
- /// The bootstrapper application assembly loaded by the host does not contain exactly one instance of the
55
- /// <see cref="BootstrapperApplicationFactoryAttribute"/> class.
56
- /// </summary>
57
- /// <seealso cref="BootstrapperApplicationFactoryAttribute"/>
58
- [Serializable]
59
- public class MissingAttributeException : BootstrapperException
60
- {
61
- /// <summary>
62
- /// Creates a new instance of the <see cref="MissingAttributeException"/> class.
63
- /// </summary>
64
- public MissingAttributeException()
65
- : base(NativeMethods.E_NOTFOUND)
66
- {
67
- }
68
-
69
- /// <summary>
70
- /// Initializes a new instance of the <see cref="MissingAttributeException"/> class.
71
- /// </summary>
72
- /// <param name="message">Exception message.</param>
73
- public MissingAttributeException(string message)
74
- : base(message)
75
- {
76
- }
77
-
78
- /// <summary>
79
- /// Initializes a new instance of the <see cref="MissingAttributeException"/> class.
80
- /// </summary>
81
- /// <param name="message">Exception message</param>
82
- /// <param name="innerException">Inner exception associated with this one</param>
83
- public MissingAttributeException(string message, Exception innerException)
84
- : base(message, innerException)
85
- {
86
- }
87
-
88
- /// <summary>
89
- /// Initializes a new instance of the <see cref="MissingAttributeException"/> class.
90
- /// </summary>
91
- /// <param name="info">Serialization information for this exception</param>
92
- /// <param name="context">Streaming context to serialize to</param>
93
- protected MissingAttributeException(SerializationInfo info, StreamingContext context)
94
- : base(info, context)
95
- {
96
- }
97
- }
98
-
99
- /// <summary>
100
- /// The bootstrapper application factory specified by the <see cref="BootstrapperApplicationFactoryAttribute"/>
101
- /// does not extend the <see cref="IBootstrapperApplicationFactory"/> base class.
102
- /// </summary>
103
- /// <seealso cref="BaseBootstrapperApplicationFactory"/>
104
- /// <seealso cref="BootstrapperApplicationFactoryAttribute"/>
105
- [Serializable]
106
- public class InvalidBootstrapperApplicationFactoryException : BootstrapperException
107
- {
108
- /// <summary>
109
- /// Creates a new instance of the <see cref="InvalidBootstrapperApplicationFactoryException"/> class.
110
- /// </summary>
111
- public InvalidBootstrapperApplicationFactoryException()
112
- : base(NativeMethods.E_UNEXPECTED)
113
- {
114
- }
115
-
116
- /// <summary>
117
- /// Initializes a new instance of the <see cref="InvalidBootstrapperApplicationFactoryException"/> class.
118
- /// </summary>
119
- /// <param name="message">Exception message.</param>
120
- public InvalidBootstrapperApplicationFactoryException(string message)
121
- : base(message)
122
- {
123
- }
124
-
125
- /// <summary>
126
- /// Initializes a new instance of the <see cref="InvalidBootstrapperApplicationFactoryException"/> class.
127
- /// </summary>
128
- /// <param name="message">Exception message</param>
129
- /// <param name="innerException">Inner exception associated with this one</param>
130
- public InvalidBootstrapperApplicationFactoryException(string message, Exception innerException)
131
- : base(message, innerException)
132
- {
133
- }
134
-
135
- /// <summary>
136
- /// Initializes a new instance of the <see cref="InvalidBootstrapperApplicationFactoryException"/> class.
137
- /// </summary>
138
- /// <param name="info">Serialization information for this exception</param>
139
- /// <param name="context">Streaming context to serialize to</param>
140
- protected InvalidBootstrapperApplicationFactoryException(SerializationInfo info, StreamingContext context)
141
- : base(info, context)
142
- {
143
- }
144
- }
145
-}
src/WixToolset.Mba.Core/HostSection.cs
deleted
-47
@@ -1,47 +0,0 @@
1
-// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
-
3
-namespace WixToolset.Mba.Core
4
-{
5
- using System;
6
- using System.Configuration;
7
-
8
- /// <summary>
9
- /// Handler for the Host configuration section.
10
- /// </summary>
11
- public sealed class HostSection : ConfigurationSection
12
- {
13
- private static readonly ConfigurationProperty assemblyNameProperty = new ConfigurationProperty("assemblyName", typeof(string), null, ConfigurationPropertyOptions.IsRequired);
14
- private static readonly ConfigurationProperty supportedFrameworksProperty = new ConfigurationProperty("", typeof(SupportedFrameworkElementCollection), null, ConfigurationPropertyOptions.IsDefaultCollection);
15
-
16
- /// <summary>
17
- /// Creates a new instance of the <see cref="HostSection"/> class.
18
- /// </summary>
19
- public HostSection()
20
- {
21
- }
22
-
23
- /// <summary>
24
- /// Gets the name of the assembly that contians the <see cref="BootstrapperApplication"/> child class.
25
- /// </summary>
26
- /// <remarks>
27
- /// The assembly specified by this name must contain the <see cref="BootstrapperApplicationFactoryAttribute"/> to identify
28
- /// the type of the <see cref="BootstrapperApplication"/> child class.
29
- /// </remarks>
30
- [ConfigurationProperty("assemblyName", IsRequired = true)]
31
- public string AssemblyName
32
- {
33
- get { return (string)base[assemblyNameProperty]; }
34
- set { base[assemblyNameProperty] = value; }
35
- }
36
-
37
- /// <summary>
38
- /// Gets the <see cref="SupportedFrameworkElementCollection"/> of supported frameworks for the host configuration.
39
- /// </summary>
40
- [ConfigurationProperty("", IsDefaultCollection = true)]
41
- [ConfigurationCollection(typeof(SupportedFrameworkElement))]
42
- public SupportedFrameworkElementCollection SupportedFrameworks
43
- {
44
- get { return (SupportedFrameworkElementCollection)base[supportedFrameworksProperty]; }
45
- }
46
- }
47
-}
src/WixToolset.Mba.Core/SupportedFrameworkElement.cs
deleted
-47
@@ -1,47 +0,0 @@
1
-// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
-
3
-namespace WixToolset.Mba.Core
4
-{
5
- using System;
6
- using System.Configuration;
7
-
8
- /// <summary>
9
- /// Handler for the supportedFramework configuration section.
10
- /// </summary>
11
- public sealed class SupportedFrameworkElement : ConfigurationElement
12
- {
13
- private static readonly ConfigurationProperty versionProperty = new ConfigurationProperty("version", typeof(string), null, ConfigurationPropertyOptions.IsRequired);
14
- private static readonly ConfigurationProperty runtimeVersionProperty = new ConfigurationProperty("runtimeVersion", typeof(string));
15
-
16
- /// <summary>
17
- /// Creates a new instance of the <see cref="SupportedFrameworkElement"/> class.
18
- /// </summary>
19
- public SupportedFrameworkElement()
20
- {
21
- }
22
-
23
- /// <summary>
24
- /// Gets the version of the supported framework.
25
- /// </summary>
26
- /// <remarks>
27
- /// The assembly specified by this name must contain a value matching the NETFX version registry key under
28
- /// "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP".
29
- /// </remarks>
30
- [ConfigurationProperty("version", IsRequired = true)]
31
- public string Version
32
- {
33
- get { return (string)base[versionProperty]; }
34
- set { base[versionProperty] = value; }
35
- }
36
-
37
- /// <summary>
38
- /// Gets the runtime version required by this supported framework.
39
- /// </summary>
40
- [ConfigurationProperty("runtimeVersion", IsRequired = false)]
41
- public string RuntimeVersion
42
- {
43
- get { return (string)base[runtimeVersionProperty]; }
44
- set { base[runtimeVersionProperty] = value; }
45
- }
46
- }
47
-}
src/WixToolset.Mba.Core/SupportedFrameworkElementCollection.cs
deleted
-36
@@ -1,36 +0,0 @@
1
-// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
-
3
-namespace WixToolset.Mba.Core
4
-{
5
- using System;
6
- using System.Configuration;
7
- using System.Diagnostics.CodeAnalysis;
8
-
9
- /// <summary>
10
- /// Handler for the supportedFramework collection.
11
- /// </summary>
12
- [SuppressMessage("Microsoft.Design", "CA1010:CollectionsShouldImplementGenericInterface")]
13
- [ConfigurationCollection(typeof(SupportedFrameworkElement), AddItemName = "supportedFramework", CollectionType = ConfigurationElementCollectionType.BasicMap)]
14
- public sealed class SupportedFrameworkElementCollection : ConfigurationElementCollection
15
- {
16
- public override ConfigurationElementCollectionType CollectionType
17
- {
18
- get { return ConfigurationElementCollectionType.BasicMap; }
19
- }
20
-
21
- protected override string ElementName
22
- {
23
- get { return "supportedFramework"; }
24
- }
25
-
26
- protected override ConfigurationElement CreateNewElement()
27
- {
28
- return new SupportedFrameworkElement();
29
- }
30
-
31
- protected override object GetElementKey(ConfigurationElement element)
32
- {
33
- return (element as SupportedFrameworkElement).Version;
34
- }
35
- }
36
-}
src/WixToolset.Mba.Core/WixToolset.Mba.Core.config
deleted
-26
@@ -1,26 +0,0 @@
1
-<?xml version="1.0" encoding="utf-8" ?>
2
-<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
3
-
4
-
5
-<configuration>
6
- <configSections>
7
- <sectionGroup name="wix.bootstrapper" type="WixToolset.Mba.Core.BootstrapperSectionGroup, WixToolset.Mba.Core">
8
- <section name="host" type="WixToolset.Mba.Core.HostSection, WixToolset.Mba.Core" />
9
- </sectionGroup>
10
- </configSections>
11
- <startup useLegacyV2RuntimeActivationPolicy="true">
12
- <supportedRuntime version="v4.0" />
13
- <supportedRuntime version="v2.0.50727" />
14
- </startup>
15
- <wix.bootstrapper>
16
- <!-- Example only. Use only if the startup/supportedRuntime above cannot discern supported frameworks. -->
17
- <!--
18
- <supportedFramework version="v4\Client" />
19
- <supportedFramework version="v3.5" />
20
- <supportedFramework version="v3.0" />
21
- -->
22
-
23
- <!-- Example only. Replace the host/@assemblyName attribute with assembly that implements IBootstrapperApplicationFactory. -->
24
- <host assemblyName="AssemblyWithClassThatInheritsFromBootstrapperApplicationFactory" />
25
- </wix.bootstrapper>
26
-</configuration>
src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj
+1
-36
@@ -10,7 +10,7 @@
10
<RootNamespace>WixToolset.Mba.Core</RootNamespace>
11
<NoWarn>0693;1591</NoWarn>
12
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
13
- <Description>Managed Bootstrapper Application entry point</Description>
13
+ <Description>Managed Bootstrapper Application Core</Description>
14
</PropertyGroup>
15
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
16
<DebugSymbols>true</DebugSymbols>
@@ -27,15 +27,11 @@
27
<Compile Include="BaseBootstrapperApplicationFactory.cs" />
28
<Compile Include="BootstrapperApplication.cs" />
29
<Compile Include="BootstrapperApplicationData.cs" />
30
- <Compile Include="BootstrapperApplicationFactory.cs" />
30
<Compile Include="BootstrapperApplicationFactoryAttribute.cs" />
31
<Compile Include="BootstrapperCommand.cs" />
33
- <Compile Include="BootstrapperSectionGroup.cs" />
32
<Compile Include="BundleInfo.cs" />
33
<Compile Include="Engine.cs" />
34
<Compile Include="EventArgs.cs" />
37
- <Compile Include="Exceptions.cs" />
38
- <Compile Include="HostSection.cs" />
35
<Compile Include="IBootstrapperApplication.cs" />
36
<Compile Include="IBootstrapperApplicationData.cs" />
37
<Compile Include="IBootstrapperApplicationFactory.cs" />
@@ -49,13 +45,6 @@
45
<Compile Include="NativeMethods.cs" />
46
<Compile Include="PackageInfo.cs" />
47
<Compile Include="Properties\AssemblyInfo.cs" />
52
- <Compile Include="SupportedFrameworkElementCollection.cs" />
53
- <Compile Include="SupportedFrameworkElement.cs" />
54
- </ItemGroup>
55
- <ItemGroup>
56
- <Content Include="WixToolset.Mba.Core.config">
57
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
58
- </Content>
48
</ItemGroup>
49
<ItemGroup>
50
<None Include="packages.config" />
@@ -66,33 +55,9 @@
55
<Reference Include="System.Data" />
56
<Reference Include="System.Xml" />
57
</ItemGroup>
69
- <ItemGroup>
70
- <HeaderPath Include="$(BaseOutputPath)$(Configuration)\$(AssemblyName).h">
71
- <Visible>False</Visible>
72
- </HeaderPath>
73
- </ItemGroup>
58
59
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
60
77
- <Target Name="GenerateIdentityHeader" AfterTargets="Build" Inputs="$(TargetPath)" Outputs="@(HeaderPath)">
78
- <GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
79
- <Output TaskParameter="Assemblies" ItemName="AssemblyIdentity" />
80
- </GetAssemblyIdentity>
81
- <ItemGroup>
82
- <Line Include="#define MBA_ASSEMBLY_FULL_NAME L"%(AssemblyIdentity.Identity)"" />
83
- <Line Include="#define MBA_ASSEMBLY_NAME L"%(AssemblyIdentity.Name)"" />
84
- <Line Include="#define MBA_ASSEMBLY_VERSION L"%(AssemblyIdentity.Version)"" />
85
- <Line Include="#define MBA_ASSEMBLY_CULTURE L"%(AssemblyIdentity.Culture)"" Condition="'%(AssemblyIdentity.Culture)'!=''" />
86
- <Line Include="#define MBA_ASSEMBLY_CULTURE L"neutral"" Condition="'%(AssemblyIdentity.Culture)'==''" />
87
- <Line Include="#define MBA_ASSEMBLY_PUBLICKEYTOKEN L"%(AssemblyIdentity.PublicKeyToken)"" />
88
- </ItemGroup>
89
- <Message Importance="normal" Text="Generating identity definitions into @(HeaderPath->'%(FullPath)')" />
90
- <WriteLinesToFile File="@(HeaderPath)" Lines="@(Line)" Overwrite="True" />
91
- <ItemGroup>
92
- <FileWrites Include="@(HeaderPath)" />
93
- </ItemGroup>
94
- </Target>
95
-
61
<Target Name="Pack" DependsOnTargets="GetBuildVersion">
62
<Exec Command='nuget pack $(AssemblyName).nuspec -OutputDirectory "$(BaseOutputPath)$(Configuration)" -Properties Configuration=$(Configuration);Id=$(AssemblyName);Version="$(BuildVersionSimple)";Authors="$(Authors)";Copyright="$(Copyright)";Description="$(Description)";Title="$(Title)"' />
63
</Target>
src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec
-2
@@ -14,10 +14,8 @@
14
</metadata>
15
16
<files>
17
- <file src="..\..\build\$configuration$\$id$.config" target="samples" />
17
<file src="build\net20\$id$.props" target="build\net20" />
18
<file src="..\..\build\$configuration$\v141_xp\x86\mbanative.dll" target="build\net20\x86" />
20
- <file src="..\..\build\$configuration$\$id$.h" target="build\native\include" />
19
<file src="..\..\build\$configuration$\$id$.dll" target="lib\net20" />
20
</files>
21
</package>