@joebigelow / wix / commits / 57fd164d

Replace Dnc.Host with Dnc.HostGenerator to support linker trimming.

Sean Hall committed Apr 19, 2022 at 17:15 UTC 57fd164d56466a52854e825afd5fdc2b6b97f12a
48 files changed +626 -565
src/clean.cmd
+1
@@ -27,6 +27,7 @@ if exist "%_NUGET_CACHE%\wixtoolset.core.testpackage" rd /s/q "%_NUGET_CACHE%\wi
27 if exist "%_NUGET_CACHE%\wixtoolset.core.windowsinstaller" rd /s/q "%_NUGET_CACHE%\wixtoolset.core.windowsinstaller"
28 if exist "%_NUGET_CACHE%\wixtoolset.data" rd /s/q "%_NUGET_CACHE%\wixtoolset.data"
29 if exist "%_NUGET_CACHE%\wixtoolset.dependency.wixext" rd /s/q "%_NUGET_CACHE%\wixtoolset.dependency.wixext"
30 +if exist "%_NUGET_CACHE%\wixtoolset.dnc.hostgenerator" rd /s/q "%_NUGET_CACHE%\wixtoolset.dnc.hostgenerator"
31 if exist "%_NUGET_CACHE%\wixtoolset.dtf.compression" rd /s/q "%_NUGET_CACHE%\wixtoolset.dtf.compression"
32 if exist "%_NUGET_CACHE%\wixtoolset.dtf.compression.cab" rd /s/q "%_NUGET_CACHE%\wixtoolset.dtf.compression.cab"
33 if exist "%_NUGET_CACHE%\wixtoolset.dtf.customaction" rd /s/q "%_NUGET_CACHE%\wixtoolset.dtf.customaction"
src/ext/Bal/Bal.wixext.sln
+35 -17
@@ -15,7 +15,7 @@ Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "bal", "wixlib\bal.wixproj",
15 EndProject
16 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.Bal.wixext", "wixext\WixToolset.Bal.wixext.csproj", "{BF720A63-9D7B-456E-B60C-8122852D9FED}"
17 EndProject
18 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.Dnc.Host", "WixToolset.Dnc.Host\WixToolset.Dnc.Host.csproj", "{0D780900-C2FF-4FA2-8CB5-8A19768724C5}"
18 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.Dnc.HostGenerator", "WixToolset.Dnc.HostGenerator\WixToolset.Dnc.HostGenerator.csproj", "{D6A58B36-D47E-4020-A130-58B0CEAF01A2}"
19 EndProject
20 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.Mba.Host", "WixToolset.Mba.Host\WixToolset.Mba.Host.csproj", "{F2BA1935-70FA-4156-B161-FD03850B4FAA}"
21 EndProject
@@ -23,6 +23,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.FullFramework2MBA",
23 EndProject
24 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Example.TestEngine", "test\examples\TestEngine\Example.TestEngine.vcxproj", "{3D44B67D-A475-49BA-8310-E39F6C117CC9}"
25 EndProject
26 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolsetTest.Dnc.HostGenerator", "test\WixToolsetTest.Dnc.HostGenerator\WixToolsetTest.Dnc.HostGenerator.csproj", "{38D80FC7-EBD4-4902-A114-C93AA75CFCA0}"
27 +EndProject
28 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolsetTest.ManagedHost", "test\WixToolsetTest.ManagedHost\WixToolsetTest.ManagedHost.csproj", "{FED9D707-E5C3-4867-87B0-FABDB5EB0823}"
29 EndProject
30 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.FullFramework4MBA", "test\examples\FullFramework4MBA\Example.FullFramework4MBA.csproj", "{44297646-706D-4508-8E96-1B35B109694C}"
@@ -125,22 +127,22 @@ Global
127 {BF720A63-9D7B-456E-B60C-8122852D9FED}.Release|x64.Build.0 = Release|Any CPU
128 {BF720A63-9D7B-456E-B60C-8122852D9FED}.Release|x86.ActiveCfg = Release|Any CPU
129 {BF720A63-9D7B-456E-B60C-8122852D9FED}.Release|x86.Build.0 = Release|Any CPU
128 - {0D780900-C2FF-4FA2-8CB5-8A19768724C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
129 - {0D780900-C2FF-4FA2-8CB5-8A19768724C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
130 - {0D780900-C2FF-4FA2-8CB5-8A19768724C5}.Debug|ARM64.ActiveCfg = Debug|Any CPU
131 - {0D780900-C2FF-4FA2-8CB5-8A19768724C5}.Debug|ARM64.Build.0 = Debug|Any CPU
132 - {0D780900-C2FF-4FA2-8CB5-8A19768724C5}.Debug|x64.ActiveCfg = Debug|Any CPU
133 - {0D780900-C2FF-4FA2-8CB5-8A19768724C5}.Debug|x64.Build.0 = Debug|Any CPU
134 - {0D780900-C2FF-4FA2-8CB5-8A19768724C5}.Debug|x86.ActiveCfg = Debug|Any CPU
135 - {0D780900-C2FF-4FA2-8CB5-8A19768724C5}.Debug|x86.Build.0 = Debug|Any CPU
136 - {0D780900-C2FF-4FA2-8CB5-8A19768724C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
137 - {0D780900-C2FF-4FA2-8CB5-8A19768724C5}.Release|Any CPU.Build.0 = Release|Any CPU
138 - {0D780900-C2FF-4FA2-8CB5-8A19768724C5}.Release|ARM64.ActiveCfg = Release|Any CPU
139 - {0D780900-C2FF-4FA2-8CB5-8A19768724C5}.Release|ARM64.Build.0 = Release|Any CPU
140 - {0D780900-C2FF-4FA2-8CB5-8A19768724C5}.Release|x64.ActiveCfg = Release|Any CPU
141 - {0D780900-C2FF-4FA2-8CB5-8A19768724C5}.Release|x64.Build.0 = Release|Any CPU
142 - {0D780900-C2FF-4FA2-8CB5-8A19768724C5}.Release|x86.ActiveCfg = Release|Any CPU
143 - {0D780900-C2FF-4FA2-8CB5-8A19768724C5}.Release|x86.Build.0 = Release|Any CPU
130 + {D6A58B36-D47E-4020-A130-58B0CEAF01A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
131 + {D6A58B36-D47E-4020-A130-58B0CEAF01A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
132 + {D6A58B36-D47E-4020-A130-58B0CEAF01A2}.Debug|ARM64.ActiveCfg = Debug|AnyCPU
133 + {D6A58B36-D47E-4020-A130-58B0CEAF01A2}.Debug|ARM64.Build.0 = Debug|AnyCPU
134 + {D6A58B36-D47E-4020-A130-58B0CEAF01A2}.Debug|x64.ActiveCfg = Debug|AnyCPU
135 + {D6A58B36-D47E-4020-A130-58B0CEAF01A2}.Debug|x64.Build.0 = Debug|AnyCPU
136 + {D6A58B36-D47E-4020-A130-58B0CEAF01A2}.Debug|x86.ActiveCfg = Debug|AnyCPU
137 + {D6A58B36-D47E-4020-A130-58B0CEAF01A2}.Debug|x86.Build.0 = Debug|AnyCPU
138 + {D6A58B36-D47E-4020-A130-58B0CEAF01A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
139 + {D6A58B36-D47E-4020-A130-58B0CEAF01A2}.Release|Any CPU.Build.0 = Release|Any CPU
140 + {D6A58B36-D47E-4020-A130-58B0CEAF01A2}.Release|ARM64.ActiveCfg = Release|AnyCPU
141 + {D6A58B36-D47E-4020-A130-58B0CEAF01A2}.Release|ARM64.Build.0 = Release|AnyCPU
142 + {D6A58B36-D47E-4020-A130-58B0CEAF01A2}.Release|x64.ActiveCfg = Release|AnyCPU
143 + {D6A58B36-D47E-4020-A130-58B0CEAF01A2}.Release|x64.Build.0 = Release|AnyCPU
144 + {D6A58B36-D47E-4020-A130-58B0CEAF01A2}.Release|x86.ActiveCfg = Release|AnyCPU
145 + {D6A58B36-D47E-4020-A130-58B0CEAF01A2}.Release|x86.Build.0 = Release|AnyCPU
146 {F2BA1935-70FA-4156-B161-FD03850B4FAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
147 {F2BA1935-70FA-4156-B161-FD03850B4FAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
148 {F2BA1935-70FA-4156-B161-FD03850B4FAA}.Debug|ARM64.ActiveCfg = Debug|Any CPU
@@ -189,6 +191,22 @@ Global
191 {3D44B67D-A475-49BA-8310-E39F6C117CC9}.Release|x64.Build.0 = Release|x64
192 {3D44B67D-A475-49BA-8310-E39F6C117CC9}.Release|x86.ActiveCfg = Release|Win32
193 {3D44B67D-A475-49BA-8310-E39F6C117CC9}.Release|x86.Build.0 = Release|Win32
194 + {38D80FC7-EBD4-4902-A114-C93AA75CFCA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
195 + {38D80FC7-EBD4-4902-A114-C93AA75CFCA0}.Debug|Any CPU.Build.0 = Debug|Any CPU
196 + {38D80FC7-EBD4-4902-A114-C93AA75CFCA0}.Debug|ARM64.ActiveCfg = Debug|Any CPU
197 + {38D80FC7-EBD4-4902-A114-C93AA75CFCA0}.Debug|ARM64.Build.0 = Debug|Any CPU
198 + {38D80FC7-EBD4-4902-A114-C93AA75CFCA0}.Debug|x64.ActiveCfg = Debug|Any CPU
199 + {38D80FC7-EBD4-4902-A114-C93AA75CFCA0}.Debug|x64.Build.0 = Debug|Any CPU
200 + {38D80FC7-EBD4-4902-A114-C93AA75CFCA0}.Debug|x86.ActiveCfg = Debug|Any CPU
201 + {38D80FC7-EBD4-4902-A114-C93AA75CFCA0}.Debug|x86.Build.0 = Debug|Any CPU
202 + {38D80FC7-EBD4-4902-A114-C93AA75CFCA0}.Release|Any CPU.ActiveCfg = Release|Any CPU
203 + {38D80FC7-EBD4-4902-A114-C93AA75CFCA0}.Release|Any CPU.Build.0 = Release|Any CPU
204 + {38D80FC7-EBD4-4902-A114-C93AA75CFCA0}.Release|ARM64.ActiveCfg = Release|Any CPU
205 + {38D80FC7-EBD4-4902-A114-C93AA75CFCA0}.Release|ARM64.Build.0 = Release|Any CPU
206 + {38D80FC7-EBD4-4902-A114-C93AA75CFCA0}.Release|x64.ActiveCfg = Release|Any CPU
207 + {38D80FC7-EBD4-4902-A114-C93AA75CFCA0}.Release|x64.Build.0 = Release|Any CPU
208 + {38D80FC7-EBD4-4902-A114-C93AA75CFCA0}.Release|x86.ActiveCfg = Release|Any CPU
209 + {38D80FC7-EBD4-4902-A114-C93AA75CFCA0}.Release|x86.Build.0 = Release|Any CPU
210 {FED9D707-E5C3-4867-87B0-FABDB5EB0823}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
211 {FED9D707-E5C3-4867-87B0-FABDB5EB0823}.Debug|Any CPU.Build.0 = Debug|Any CPU
212 {FED9D707-E5C3-4867-87B0-FABDB5EB0823}.Debug|ARM64.ActiveCfg = Debug|Any CPU
src/ext/Bal/WixToolset.Dnc.Host/BootstrapperApplicationFactory.cs deleted
-89
@@ -1,89 +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.Dnc.Host
4 -{
5 - using System;
6 - using System.Linq;
7 - using System.Reflection;
8 - using System.Runtime.InteropServices;
9 -
10 - delegate IBootstrapperApplicationFactory StaticEntryDelegate([MarshalAs(UnmanagedType.LPWStr)] string baFactoryAssemblyName, [MarshalAs(UnmanagedType.LPWStr)] string baFactoryAssemblyPath);
11 -
12 - /// <summary>
13 - /// Entry point for the .NET Core host to create and return the BA to the engine.
14 - /// Reflection is used instead of referencing WixToolset.Mba.Core directly to avoid requiring it in the AssemblyLoadContext.
15 - /// </summary>
16 - public sealed class BootstrapperApplicationFactory : IBootstrapperApplicationFactory
17 - {
18 - private string baFactoryAssemblyName;
19 - private string baFactoryAssemblyPath;
20 -
21 - public BootstrapperApplicationFactory(string baFactoryAssemblyName, string baFactoryAssemblyPath)
22 - {
23 - this.baFactoryAssemblyName = baFactoryAssemblyName;
24 - this.baFactoryAssemblyPath = baFactoryAssemblyPath;
25 - }
26 -
27 - /// <summary>
28 - /// Loads the bootstrapper application assembly and calls its IBootstrapperApplicationFactory.Create method.
29 - /// </summary>
30 - /// <param name="pArgs">Pointer to BOOTSTRAPPER_CREATE_ARGS struct.</param>
31 - /// <param name="pResults">Pointer to BOOTSTRAPPER_CREATE_RESULTS struct.</param>
32 - /// <exception cref="MissingAttributeException">The bootstrapper application assembly
33 - /// does not define the <see cref="BootstrapperApplicationFactoryAttribute"/>.</exception>
34 - public void Create(IntPtr pArgs, IntPtr pResults)
35 - {
36 - // Load the BA's IBootstrapperApplicationFactory.
37 - var baFactoryType = BootstrapperApplicationFactory.GetBAFactoryTypeFromAssembly(this.baFactoryAssemblyName, this.baFactoryAssemblyPath);
38 - var baFactory = Activator.CreateInstance(baFactoryType);
39 - if (null == baFactory)
40 - {
41 - throw new InvalidBootstrapperApplicationFactoryException();
42 - }
43 -
44 - var createMethod = baFactoryType.GetMethod(nameof(Create), new[] { typeof(IntPtr), typeof(IntPtr) });
45 - if (null == createMethod)
46 - {
47 - throw new InvalidBootstrapperApplicationFactoryException();
48 - }
49 - createMethod.Invoke(baFactory, new object[] { pArgs, pResults });
50 - }
51 -
52 - /// <summary>
53 - /// Locates the <see cref="BootstrapperApplicationFactoryAttribute"/> and returns the specified type.
54 - /// </summary>
55 - /// <param name="assemblyName">The assembly that defines the IBootstrapperApplicationFactory implementation.</param>
56 - /// <returns>The bootstrapper application factory <see cref="Type"/>.</returns>
57 - private static Type GetBAFactoryTypeFromAssembly(string assemblyName, string assemblyPath)
58 - {
59 - // The default ALC shouldn't need help loading the assembly, since the host should have provided the deps.json
60 - // when starting the runtime. But it doesn't hurt so keep this in case an isolated ALC is ever needed.
61 - var alc = new DnchostAssemblyLoadContext(assemblyPath, false);
62 - var asm = alc.LoadFromAssemblyName(new AssemblyName(assemblyName));
63 -
64 - var attr = asm.GetCustomAttributes()
65 - .Where(a => a.GetType().FullName == "WixToolset.Mba.Core.BootstrapperApplicationFactoryAttribute")
66 - .SingleOrDefault();
67 -
68 - if (null == attr)
69 - {
70 - throw new MissingAttributeException();
71 - }
72 -
73 - var baFactoryTypeProperty = attr.GetType().GetProperty("BootstrapperApplicationFactoryType", typeof(Type));
74 - if (baFactoryTypeProperty == null || baFactoryTypeProperty.GetMethod == null)
75 - {
76 - throw new MissingAttributeException();
77 - }
78 -
79 - var baFactoryType = (Type)baFactoryTypeProperty.GetMethod.Invoke(attr, null);
80 - return baFactoryType;
81 - }
82 -
83 - // Entry point for the DNC host.
84 - public static IBootstrapperApplicationFactory CreateBAFactory([MarshalAs(UnmanagedType.LPWStr)] string baFactoryAssemblyName, [MarshalAs(UnmanagedType.LPWStr)] string baFactoryAssemblyPath)
85 - {
86 - return new BootstrapperApplicationFactory(baFactoryAssemblyName, baFactoryAssemblyPath);
87 - }
88 - }
89 -}
src/ext/Bal/WixToolset.Dnc.Host/DnchostAssemblyLoadContext.cs deleted
-58
@@ -1,58 +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.Dnc.Host
4 -{
5 - using System;
6 - using System.Reflection;
7 - using System.Runtime.Loader;
8 -
9 - public sealed class DnchostAssemblyLoadContext : AssemblyLoadContext
10 - {
11 - private readonly AssemblyDependencyResolver resolver;
12 -
13 - public DnchostAssemblyLoadContext(string assemblyPath, bool isolateFromDefault)
14 - : base(nameof(DnchostAssemblyLoadContext), isolateFromDefault)
15 - {
16 - this.resolver = new AssemblyDependencyResolver(assemblyPath);
17 -
18 - if (!this.IsCollectible)
19 - {
20 - AssemblyLoadContext.Default.Resolving += this.ResolveAssembly;
21 - AssemblyLoadContext.Default.ResolvingUnmanagedDll += this.ResolveUnmanagedDll;
22 - }
23 - }
24 -
25 - private Assembly ResolveAssembly(AssemblyLoadContext defaultAlc, AssemblyName assemblyName)
26 - {
27 - var path = this.resolver.ResolveAssemblyToPath(assemblyName);
28 - if (path != null)
29 - {
30 - var targetAlc = this.IsCollectible ? this : defaultAlc;
31 - return targetAlc.LoadFromAssemblyPath(path);
32 - }
33 -
34 - return null;
35 - }
36 -
37 - private IntPtr ResolveUnmanagedDll(Assembly assembly, string unmanagedDllName)
38 - {
39 - var path = this.resolver.ResolveUnmanagedDllToPath(unmanagedDllName);
40 - if (path != null)
41 - {
42 - return this.LoadUnmanagedDllFromPath(path);
43 - }
44 -
45 - return IntPtr.Zero;
46 - }
47 -
48 - protected override Assembly Load(AssemblyName assemblyName)
49 - {
50 - return this.ResolveAssembly(AssemblyLoadContext.Default, assemblyName);
51 - }
52 -
53 - protected override IntPtr LoadUnmanagedDll(string unmanagedDllName)
54 - {
55 - return this.ResolveUnmanagedDll(null, unmanagedDllName);
56 - }
57 - }
58 -}
src/ext/Bal/WixToolset.Dnc.Host/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.Dnc.Host
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="Core.BootstrapperApplicationFactoryAttribute"/> class.
56 - /// </summary>
57 - /// <seealso cref="Core.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="Core.BootstrapperApplicationFactoryAttribute"/>
101 - /// does not extend the <see cref="Core.IBootstrapperApplicationFactory"/> base class.
102 - /// </summary>
103 - /// <seealso cref="Core.BaseBootstrapperApplicationFactory"/>
104 - /// <seealso cref="Core.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/ext/Bal/WixToolset.Dnc.Host/IBootstrapperApplicationFactory.cs deleted
-16
@@ -1,16 +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.Dnc.Host
4 -{
5 - using System;
6 - using System.Runtime.InteropServices;
7 -
8 - [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
9 - public interface IBootstrapperApplicationFactory
10 - {
11 - void Create(
12 - IntPtr pArgs,
13 - IntPtr pResults
14 - );
15 - }
16 -}
src/ext/Bal/WixToolset.Dnc.Host/NativeMethods.cs deleted
-18
@@ -1,18 +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.Dnc.Host
4 -{
5 - using System;
6 - using System.Runtime.InteropServices;
7 -
8 - /// <summary>
9 - /// Contains native constants, functions, and structures for this assembly.
10 - /// </summary>
11 - internal static class NativeMethods
12 - {
13 - #region Error Constants
14 - internal const int E_NOTFOUND = unchecked((int)0x80070490);
15 - internal const int E_UNEXPECTED = unchecked((int)0x8000ffff);
16 - #endregion
17 - }
18 -}
src/ext/Bal/WixToolset.Dnc.Host/WixToolset.Dnc.Host.csproj deleted
-39
@@ -1,39 +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 -<Project Sdk="Microsoft.NET.Sdk">
5 - <PropertyGroup>
6 - <TargetFramework>netcoreapp3.1</TargetFramework>
7 - <RootNamespace>WixToolset.Dnc.Host</RootNamespace>
8 - <Description>WiX Toolset .NET Core BA Host</Description>
9 - <Title>WiX Toolset .NET Core BA Host</Title>
10 - <DebugType>embedded</DebugType>
11 - <PlatformTarget>AnyCPU</PlatformTarget>
12 - </PropertyGroup>
13 -
14 - <ItemGroup>
15 - <HeaderPath Include="$(BaseOutputPath)obj\$(AssemblyName).h">
16 - <Visible>False</Visible>
17 - </HeaderPath>
18 - </ItemGroup>
19 -
20 - <Target Name="GenerateIdentityHeader" AfterTargets="Build" Inputs="$(TargetPath)" Outputs="@(HeaderPath)">
21 - <GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
22 - <Output TaskParameter="Assemblies" ItemName="AssemblyIdentity" />
23 - </GetAssemblyIdentity>
24 - <ItemGroup>
25 - <Line Include='#define DNC_ASSEMBLY_FILE_NAME L"$(AssemblyName).dll"' />
26 - <Line Include='#define DNC_ASSEMBLY_FULL_NAME "%(AssemblyIdentity.Identity)"' />
27 - <Line Include='#define DNC_ENTRY_TYPE "$(RootNamespace).BootstrapperApplicationFactory"' />
28 - <Line Include='#define DNC_ENTRY_TYPEW L"$(RootNamespace).BootstrapperApplicationFactory,$(AssemblyName)"' />
29 - <Line Include='#define DNC_STATIC_ENTRY_METHOD "CreateBAFactory"' />
30 - <Line Include='#define DNC_STATIC_ENTRY_METHODW L"CreateBAFactory"' />
31 - <Line Include='#define DNC_STATIC_ENTRY_DELEGATEW L"$(RootNamespace).StaticEntryDelegate,$(AssemblyName)"' />
32 - </ItemGroup>
33 - <Message Importance="normal" Text="Generating identity definitions into @(HeaderPath->'%(FullPath)')" />
34 - <WriteLinesToFile File="@(HeaderPath)" Lines="@(Line)" Overwrite="True" />
35 - <ItemGroup>
36 - <FileWrites Include="@(HeaderPath)" />
37 - </ItemGroup>
38 - </Target>
39 -</Project>
src/ext/Bal/WixToolset.Dnc.HostGenerator/DncHostGenerator.cs new
+127
@@ -0,0 +1,127 @@
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.Dnc.HostGenerator
4 +{
5 + using System;
6 + using System.Diagnostics.CodeAnalysis;
7 + using System.Text;
8 + using Microsoft.CodeAnalysis;
9 + using Microsoft.CodeAnalysis.Text;
10 +
11 + [Generator]
12 + public sealed class DncHostGenerator : ISourceGenerator
13 + {
14 + public static readonly string Version = String.Format($"{ThisAssembly.Git.SemVer.Major}.{ThisAssembly.Git.SemVer.Minor}.{ThisAssembly.Git.SemVer.Patch}{ThisAssembly.Git.SemVer.DashLabel}+{ThisAssembly.Git.Sha}");
15 + public static readonly string TargetAttributeFullName = "WixToolset.Mba.Core.BootstrapperApplicationFactoryAttribute";
16 +
17 + [SuppressMessage("MicrosoftCodeAnalysisReleaseTracking", "RS2008:Enable analyzer release tracking", Justification = "Tracking not needed")]
18 + public static readonly DiagnosticDescriptor MissingFactoryAttributeDescriptor = new DiagnosticDescriptor(
19 + "WIXBAL001",
20 + $"Missing assembly level attribute {TargetAttributeFullName}.",
21 + $"Add [assembly: {TargetAttributeFullName}(typeof(<your IBootstrapperApplicationFactory>)].",
22 + "WixToolset.Bal.wixext",
23 + DiagnosticSeverity.Error,
24 + true
25 + );
26 +
27 + public void Initialize(GeneratorInitializationContext context)
28 + {
29 + }
30 +
31 + public void Execute(GeneratorExecutionContext context)
32 + {
33 + var symbolDisplayFormat = new SymbolDisplayFormat(typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces);
34 +
35 + string baFactoryClassName = null;
36 + foreach (var assemblyAttribute in context.Compilation.Assembly.GetAttributes())
37 + {
38 + var fullAssemblyTypeName = assemblyAttribute.AttributeClass.ToDisplayString(symbolDisplayFormat);
39 +
40 + if (fullAssemblyTypeName == TargetAttributeFullName &&
41 + assemblyAttribute.ConstructorArguments.Length == 1)
42 + {
43 + var arg = assemblyAttribute.ConstructorArguments[0];
44 + if (arg.Value is INamedTypeSymbol argValue)
45 + {
46 + baFactoryClassName = argValue.ToDisplayString(symbolDisplayFormat);
47 + break;
48 + }
49 + }
50 + }
51 +
52 + if (baFactoryClassName == null)
53 + {
54 + context.ReportDiagnostic(Diagnostic.Create(MissingFactoryAttributeDescriptor, null));
55 + }
56 + else
57 + {
58 + var source = String.Format(Template, Version, baFactoryClassName);
59 + context.AddSource("WixToolset.Dnc.Host.g.cs", SourceText.From(source, Encoding.UTF8, SourceHashAlgorithm.Sha256));
60 + }
61 + }
62 +
63 + public const string Template = @"
64 +//------------------------------------------------------------------------------
65 +// <auto-generated>
66 +// This code was generated by a tool.
67 +//
68 +// Changes to this file may cause incorrect behavior and will be lost if
69 +// the code is regenerated.
70 +// </auto-generated>
71 +//------------------------------------------------------------------------------
72 +
73 +namespace WixToolset.Dnc.Host
74 +{{
75 + using System;
76 + using System.CodeDom.Compiler;
77 + using System.Diagnostics.CodeAnalysis;
78 + using System.Linq;
79 + using System.Reflection;
80 + using System.Runtime.CompilerServices;
81 + using System.Runtime.InteropServices;
82 + using WixToolset.Mba.Core;
83 +
84 + [GeneratedCode(""WixToolset.Dnc.HostGenerator.DncHostGenerator"", ""{0}"")]
85 + [CompilerGenerated]
86 + delegate IBootstrapperApplicationFactory StaticEntryDelegate();
87 +
88 + /// <summary>
89 + /// Entry point for the .NET Core host to create and return the BA to the engine.
90 + /// </summary>
91 + [GeneratedCode(""WixToolset.Dnc.HostGenerator.DncHostGenerator"", ""{0}"")]
92 + [CompilerGenerated]
93 + public sealed class BootstrapperApplicationFactory : IBootstrapperApplicationFactory
94 + {{
95 + /// <summary>
96 + /// Creates the bootstrapper application factory and calls its IBootstrapperApplicationFactory.Create method.
97 + /// </summary>
98 + /// <param name=""pArgs"">Pointer to BOOTSTRAPPER_CREATE_ARGS struct.</param>
99 + /// <param name=""pResults"">Pointer to BOOTSTRAPPER_CREATE_RESULTS struct.</param>
100 + public void Create(IntPtr pArgs, IntPtr pResults)
101 + {{
102 + var baFactory = new {1}();
103 + baFactory.Create(pArgs, pResults);
104 + }}
105 +
106 + // Entry point for the DNC host.
107 + public static IBootstrapperApplicationFactory CreateBAFactory()
108 + {{
109 + return new BootstrapperApplicationFactory();
110 + }}
111 +
112 +#if NET5_0_OR_GREATER
113 + [ModuleInitializer]
114 + [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(BootstrapperApplicationFactory))]
115 +#if NET5_0
116 + [DynamicDependency(""GetFunctionPointer(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr)"", ""Internal.Runtime.InteropServices.ComponentActivator"", ""System.Private.CoreLib"")]
117 +#endif
118 + /// <summary>
119 + /// Empty method to attach above attributes to support linker trimming.
120 + /// </summary>
121 + public static void ModuleInitialize() {{ }}
122 +#endif
123 + }}
124 +}}
125 +";
126 + }
127 +}
src/ext/Bal/WixToolset.Dnc.HostGenerator/WixToolset.Dnc.HostGenerator.csproj new
+27
@@ -0,0 +1,27 @@
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>netstandard2.0</TargetFramework>
7 + <RootNamespace>WixToolset.Dnc.HostGenerator</RootNamespace>
8 + <Description>WiX Toolset .NET Core BA Host Generator</Description>
9 + <Title>WiX Toolset .NET Core BA Host Generator</Title>
10 + <DebugType>embedded</DebugType>
11 + <PlatformTarget>AnyCPU</PlatformTarget>
12 + <GitThisAssembly>true</GitThisAssembly>
13 + </PropertyGroup>
14 +
15 + <ItemGroup>
16 + <Content Include="build\$(AssemblyName).props" CopyToOutputDirectory="PreserveNewest" />
17 + <Content Include="build\$(AssemblyName).targets" CopyToOutputDirectory="PreserveNewest" />
18 + </ItemGroup>
19 +
20 + <ItemGroup>
21 + <PackageReference Include="Microsoft.CodeAnalysis.CSharp" PrivateAssets="all" />
22 + <PackageReference Include="Microsoft.CodeAnalysis.Analyzers">
23 + <PrivateAssets>all</PrivateAssets>
24 + <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
25 + </PackageReference>
26 + </ItemGroup>
27 +</Project>
src/ext/Bal/WixToolset.Dnc.HostGenerator/WixToolset.Dnc.HostGenerator.nuspec new
+23
@@ -0,0 +1,23 @@
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
3 + <metadata>
4 + <id>$id$</id>
5 + <version>$version$</version>
6 + <title>$title$</title>
7 + <description>$description$</description>
8 + <authors>$authors$</authors>
9 + <license type="expression">MS-RL</license>
10 + <requireLicenseAcceptance>false</requireLicenseAcceptance>
11 + <copyright>$copyright$</copyright>
12 + <projectUrl>$projectUrl$</projectUrl>
13 + <repository type="$repositorytype$" url="$repositoryurl$" commit="$repositorycommit$" />
14 + <dependencies>
15 + <dependency id="WixToolset.Mba.Core" version="[$version$,5)" />
16 + </dependencies>
17 + </metadata>
18 +
19 + <files>
20 + <file src="$id$.dll" target="analyzers/dotnet/cs" />
21 + <file src="build\**\*" target="build" />
22 + </files>
23 +</package>
src/ext/Bal/WixToolset.Dnc.HostGenerator/build/WixToolset.Dnc.HostGenerator.props new
+10
@@ -0,0 +1,10 @@
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 xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="Current">
5 + <PropertyGroup>
6 + <BuiltInComInteropSupport>true</BuiltInComInteropSupport>
7 + <EnableDynamicLoading>true</EnableDynamicLoading>
8 + <_EnableConsumingManagedCodeFromNativeHosting>true</_EnableConsumingManagedCodeFromNativeHosting>
9 + </PropertyGroup>
10 +</Project>
src/ext/Bal/WixToolset.Dnc.HostGenerator/build/WixToolset.Dnc.HostGenerator.targets new
+11
@@ -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 xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="Current">
5 + <ItemGroup Condition=" '$(TrimMode)'=='CopyUsed' ">
6 + <TrimmerRootAssembly Include="System.Diagnostics.Tools" />
7 + <TrimmerRootAssembly Include="System.Runtime" />
8 + <TrimmerRootAssembly Include="System.Runtime.InteropServices" />
9 + <TrimmerRootAssembly Include="System.Runtime.Loader" />
10 + </ItemGroup>
11 +</Project>
src/ext/Bal/bal.cmd
+6 -1
@@ -2,11 +2,12 @@
2 @pushd %~dp0
3
4 @set _C=Debug
5 +@set _L=%~dp0..\..\..\build\logs
6 :parse_args
7 @if /i "%1"=="release" set _C=Release
8 @if not "%1"=="" shift & goto parse_args
9
9 -@echo Building ext\Util %_C% using %_N%
10 +@echo Building ext\Bal %_C% using %_N%
11
12 :: Restore
13 nuget restore dnchost\packages.config || exit /b
@@ -22,6 +23,9 @@ msbuild -p:Configuration=%_C%;Platform=x64 mbahost\mbahost.vcxproj || exit /b
23 msbuild -p:Configuration=%_C%;Platform=ARM64 mbahost\mbahost.vcxproj || exit /b
24
25 msbuild -p:Configuration=%_C% || exit /b
26 +
27 +dotnet test test\WixToolsetTest.Dnc.HostGenerator -c %_C% --nologo --no-build -l "trx;LogFileName=%_L%\TestResults\WixToolsetTest.Dnc.HostGenerator.trx" || exit /b
28 +
29 msbuild -p:Configuration=%_C% test\examples\examples.proj || exit /b
30
31 :: Test
@@ -31,6 +35,7 @@ dotnet test -c %_C% --no-build test\WixToolsetTest.Bal || exit /b
35
36 :: Pack
37 msbuild -t:Pack -p:Configuration=%_C% -p:NoBuild=true wixext\WixToolset.Bal.wixext.csproj || exit /b
38 +msbuild -t:Pack -p:Configuration=%_C% -p:NoBuild=true WixToolset.Dnc.HostGenerator\WixToolset.Dnc.HostGenerator.csproj || exit /b
39 msbuild -t:Pack -p:Configuration=%_C% -p:NoBuild=true WixToolset.Mba.Host\WixToolset.Mba.Host.csproj || exit /b
40
41 @popd
src/ext/Bal/dnchost/dnchost.cpp
+1 -4
@@ -154,9 +154,6 @@ static HRESULT LoadModulePaths(
154 hr = PathGetDirectory(pState->sczModuleFullPath, &pState->sczAppBase);
155 BalExitOnFailure(hr, "Failed to get the directory of the full process path.");
156
157 - hr = PathConcat(pState->sczAppBase, DNC_ASSEMBLY_FILE_NAME, &pState->sczManagedHostPath);
158 - BalExitOnFailure(hr, "Failed to create managed host path.");
159 -
157 LExit:
158 return hr;
159 }
@@ -249,7 +246,7 @@ static HRESULT LoadRuntime(
246 hr = DnchostLoadRuntime(
247 &pState->hostfxrState,
248 pState->sczModuleFullPath,
252 - pState->sczManagedHostPath,
249 + pState->sczBaFactoryAssemblyPath,
250 pState->sczBaFactoryDepsJsonPath,
251 pState->sczBaFactoryRuntimeConfigPath);
252
src/ext/Bal/dnchost/dnchost.h
-1
@@ -23,7 +23,6 @@ struct DNCSTATE
23 HINSTANCE hInstance;
24 LPWSTR sczModuleFullPath;
25 LPWSTR sczAppBase;
26 - LPWSTR sczManagedHostPath;
26 LPWSTR sczBaFactoryAssemblyName;
27 LPWSTR sczBaFactoryAssemblyPath;
28 LPWSTR sczBaFactoryDepsJsonPath;
src/ext/Bal/dnchost/dnchost.vcxproj
-8
@@ -80,14 +80,6 @@
80 </Link>
81 </ItemDefinitionGroup>
82
83 - <ItemGroup>
84 - <ProjectReference Include="..\WixToolset.Dnc.Host\WixToolset.Dnc.Host.csproj">
85 - <Project>{0D780900-C2FF-4FA2-8CB5-8A19768724C5}</Project>
86 - <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
87 - <SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
88 - </ProjectReference>
89 - </ItemGroup>
90 -
83 <ItemGroup>
84 <PackageReference Include="WixToolset.BalUtil" />
85
src/ext/Bal/dnchost/dncutil.cpp
+33 -9
@@ -2,6 +2,12 @@
2
3 #include "precomp.h"
4
5 +#define DNC_ENTRY_TYPE "WixToolset.Dnc.Host.BootstrapperApplicationFactory"
6 +#define DNC_ENTRY_TYPEW L"WixToolset.Dnc.Host.BootstrapperApplicationFactory"
7 +#define DNC_STATIC_ENTRY_METHOD "CreateBAFactory"
8 +#define DNC_STATIC_ENTRY_METHODW L"CreateBAFactory"
9 +#define DNC_STATIC_ENTRY_DELEGATEW L"WixToolset.Dnc.Host.StaticEntryDelegate"
10 +
11 // https://github.com/dotnet/runtime/blob/master/src/installer/corehost/error_codes.h
12 #define InvalidArgFailure 0x80008081
13 #define HostApiBufferTooSmall 0x80008098
@@ -74,19 +80,28 @@ LExit:
80 HRESULT DnchostCreateFactory(
81 __in HOSTFXR_STATE* pState,
82 __in LPCWSTR wzBaFactoryAssemblyName,
77 - __in LPCWSTR wzBaFactoryAssemblyPath,
83 + __in LPCWSTR /*wzBaFactoryAssemblyPath*/,
84 __out IBootstrapperApplicationFactory** ppAppFactory
85 )
86 {
87 HRESULT hr = S_OK;
88 PFNCREATEBAFACTORY pfnCreateBAFactory = NULL;
89 + LPWSTR sczEntryType = NULL;
90 + LPWSTR sczEntryDelegate = NULL;
91 + LPSTR sczBaFactoryAssemblyName = NULL;
92
93 if (pState->pfnGetFunctionPointer)
94 {
95 + hr = StrAllocFormatted(&sczEntryType, L"%ls,%ls", DNC_ENTRY_TYPEW, wzBaFactoryAssemblyName);
96 + BalExitOnFailure(hr, "Failed to format entry type.");
97 +
98 + hr = StrAllocFormatted(&sczEntryDelegate, L"%ls,%ls", DNC_STATIC_ENTRY_DELEGATEW, wzBaFactoryAssemblyName);
99 + BalExitOnFailure(hr, "Failed to format entry delegate.");
100 +
101 hr = pState->pfnGetFunctionPointer(
87 - DNC_ENTRY_TYPEW,
102 + sczEntryType,
103 DNC_STATIC_ENTRY_METHODW,
89 - DNC_STATIC_ENTRY_DELEGATEW,
104 + sczEntryDelegate,
105 NULL,
106 NULL,
107 reinterpret_cast<void**>(&pfnCreateBAFactory));
@@ -94,19 +109,26 @@ HRESULT DnchostCreateFactory(
109 }
110 else
111 {
112 + hr = StrAnsiAllocString(&sczBaFactoryAssemblyName, wzBaFactoryAssemblyName, 0, CP_UTF8);
113 + BalExitOnFailure(hr, "Failed to convert assembly name to UTF8: %ls", wzBaFactoryAssemblyName);
114 +
115 hr = pState->pfnCoreclrCreateDelegate(
116 pState->pClrHandle,
117 pState->dwDomainId,
100 - DNC_ASSEMBLY_FULL_NAME,
118 + sczBaFactoryAssemblyName,
119 DNC_ENTRY_TYPE,
120 DNC_STATIC_ENTRY_METHOD,
121 reinterpret_cast<void**>(&pfnCreateBAFactory));
122 BalExitOnFailure(hr, "Failed to create delegate in app domain.");
123 }
124
107 - *ppAppFactory = pfnCreateBAFactory(wzBaFactoryAssemblyName, wzBaFactoryAssemblyPath);
125 + *ppAppFactory = pfnCreateBAFactory();
126
127 LExit:
128 + ReleaseStr(sczEntryType);
129 + ReleaseStr(sczEntryDelegate);
130 + ReleaseStr(sczBaFactoryAssemblyName);
131 +
132 return hr;
133 }
134
@@ -233,7 +255,7 @@ static HRESULT InitializeCoreClr(
255 }
256 else
257 {
236 - ExitOnFailure(hr, "HostfxrGetRuntimeDelegate failed");
258 + BalExitOnFailure(hr, "HostfxrGetRuntimeDelegate failed");
259 }
260
261 LExit:
@@ -295,6 +317,8 @@ static HRESULT InitializeCoreClrPre5(
317
318 for (DWORD i = 0; i < cDirectories; ++i)
319 {
320 + Assert(rgDirectories);
321 +
322 hr = PathConcat(rgDirectories[i], L"coreclr.dll", &sczCoreClrPath);
323 BalExitOnFailure(hr, "Failed to allocate path to coreclr.");
324
@@ -324,9 +348,9 @@ static HRESULT InitializeCoreClrPre5(
348 BalExitOnFailure(hr, "Failed to start coreclr.");
349
350 LExit:
327 - MemFree(rgDirectories);
328 - MemFree(rgPropertyValues);
329 - MemFree(rgPropertyKeys);
351 + ReleaseMem(rgDirectories);
352 + ReleaseMem(rgPropertyValues);
353 + ReleaseMem(rgPropertyKeys);
354 ReleaseStr(sczCoreClrPath);
355
356 return hr;
src/ext/Bal/dnchost/dncutil.h
+1 -4
@@ -1,10 +1,7 @@
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 -typedef IBootstrapperApplicationFactory* (STDMETHODCALLTYPE* PFNCREATEBAFACTORY)(
5 - __in LPCWSTR wzBaFactoryAssemblyName,
6 - __in LPCWSTR wzBaFactoryAssemblyPath
7 - );
4 +typedef IBootstrapperApplicationFactory* (STDMETHODCALLTYPE* PFNCREATEBAFACTORY)();
5
6 struct HOSTFXR_STATE
7 {
src/ext/Bal/dnchost/precomp.h
-1
@@ -20,7 +20,6 @@
20 #include <IBootstrapperApplicationFactory.h>
21 #include <balutil.h>
22
23 -#include <WixToolset.Dnc.Host.h>
23 #define NETHOST_USE_AS_STATIC
24 #include <nethost.h>
25 #include <hostfxr.h>
src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/CSharpSourceGeneratorVerifier.cs new
+45
@@ -0,0 +1,45 @@
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.Dnc.HostGenerator
4 +{
5 + using System;
6 + using System.Collections.Immutable;
7 + using Microsoft.CodeAnalysis;
8 + using Microsoft.CodeAnalysis.CSharp;
9 + using Microsoft.CodeAnalysis.CSharp.Testing;
10 + using Microsoft.CodeAnalysis.Testing.Verifiers;
11 +
12 + public static class CSharpSourceGeneratorVerifier<TSourceGenerator>
13 + where TSourceGenerator : ISourceGenerator, new()
14 + {
15 + public class Test : CSharpSourceGeneratorTest<TSourceGenerator, XUnitVerifier>
16 + {
17 + public Test()
18 + {
19 + }
20 +
21 + protected override CompilationOptions CreateCompilationOptions()
22 + {
23 + var compilationOptions = base.CreateCompilationOptions();
24 + return compilationOptions.WithSpecificDiagnosticOptions(
25 + compilationOptions.SpecificDiagnosticOptions.SetItems(GetNullableWarningsFromCompiler()));
26 + }
27 +
28 + public LanguageVersion LanguageVersion { get; set; } = LanguageVersion.Default;
29 +
30 + private static ImmutableDictionary<string, ReportDiagnostic> GetNullableWarningsFromCompiler()
31 + {
32 + string[] args = { "/warnaserror:nullable" };
33 + var commandLineArguments = CSharpCommandLineParser.Default.Parse(args, baseDirectory: Environment.CurrentDirectory, sdkDirectory: Environment.CurrentDirectory);
34 + var nullableWarnings = commandLineArguments.CompilationOptions.SpecificDiagnosticOptions;
35 +
36 + return nullableWarnings;
37 + }
38 +
39 + protected override ParseOptions CreateParseOptions()
40 + {
41 + return ((CSharpParseOptions)base.CreateParseOptions()).WithLanguageVersion(this.LanguageVersion);
42 + }
43 + }
44 + }
45 +}
src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/DncHostGeneratorTests.cs new
+88
@@ -0,0 +1,88 @@
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.Dnc.HostGenerator
4 +{
5 + using System;
6 + using System.Text;
7 + using System.Threading.Tasks;
8 + using Microsoft.CodeAnalysis;
9 + using Microsoft.CodeAnalysis.Testing;
10 + using Microsoft.CodeAnalysis.Text;
11 + using WixToolset.Dnc.HostGenerator;
12 + using WixToolset.Mba.Core;
13 + using Xunit;
14 +
15 + using VerifyCS = CSharpSourceGeneratorVerifier<WixToolset.Dnc.HostGenerator.DncHostGenerator>;
16 +
17 + public class DncHostGeneratorTests
18 + {
19 + static readonly MetadataReference MbaCoreAssembly = MetadataReference.CreateFromFile(typeof(BootstrapperApplicationFactoryAttribute).Assembly.Location);
20 +
21 + [Fact]
22 + public async Task FailsBuildWhenMissingAttribute()
23 + {
24 + var code = @"
25 +//[assembly: WixToolset.Mba.Core.BootstrapperApplicationFactory(typeof(Test.BAFactory))]
26 +namespace Test
27 +{
28 + using WixToolset.Mba.Core;
29 +
30 + public class BAFactory : BaseBootstrapperApplicationFactory
31 + {
32 + protected override IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand)
33 + {
34 + return null;
35 + }
36 + }
37 +}
38 +";
39 +
40 + await new VerifyCS.Test
41 + {
42 + TestState =
43 + {
44 + Sources = { code },
45 + AdditionalReferences = { MbaCoreAssembly },
46 + ExpectedDiagnostics =
47 + {
48 + new DiagnosticResult(DncHostGenerator.MissingFactoryAttributeDescriptor),
49 + },
50 + },
51 + }.RunAsync();
52 + }
53 +
54 + [Fact]
55 + public async Task GeneratesEntryPoint()
56 + {
57 + var code = @"
58 +[assembly: WixToolset.Mba.Core.BootstrapperApplicationFactory(typeof(Test.BAFactory))]
59 +namespace Test
60 +{
61 + using WixToolset.Mba.Core;
62 +
63 + public class BAFactory : BaseBootstrapperApplicationFactory
64 + {
65 + protected override IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand)
66 + {
67 + return null;
68 + }
69 + }
70 +}
71 +";
72 + var generated = String.Format(DncHostGenerator.Template, DncHostGenerator.Version, "Test.BAFactory");
73 +
74 + await new VerifyCS.Test
75 + {
76 + TestState =
77 + {
78 + Sources = { code },
79 + GeneratedSources =
80 + {
81 + (typeof(DncHostGenerator), "WixToolset.Dnc.Host.g.cs", SourceText.From(generated, Encoding.UTF8, SourceHashAlgorithm.Sha256)),
82 + },
83 + AdditionalReferences = { MbaCoreAssembly },
84 + },
85 + }.RunAsync();
86 + }
87 + }
88 +}
src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/WixToolsetTest.Dnc.HostGenerator.csproj new
+27
@@ -0,0 +1,27 @@
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>netcoreapp3.1</TargetFramework>
7 + <IsPackable>false</IsPackable>
8 + <SignOutput>false</SignOutput>
9 + </PropertyGroup>
10 +
11 + <ItemGroup>
12 + <ProjectReference Include="..\..\WixToolset.Dnc.HostGenerator\WixToolset.Dnc.HostGenerator.csproj" />
13 + </ItemGroup>
14 +
15 + <ItemGroup>
16 + <PackageReference Include="WixBuildTools.TestSupport" />
17 + <PackageReference Include="WixToolset.Mba.Core" />
18 + </ItemGroup>
19 +
20 + <ItemGroup>
21 + <PackageReference Include="Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing.XUnit" />
22 + <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" />
23 + <PackageReference Include="Microsoft.NET.Test.Sdk" />
24 + <PackageReference Include="xunit" />
25 + <PackageReference Include="xunit.runner.visualstudio" PrivateAssets="All" />
26 + </ItemGroup>
27 +</Project>
src/ext/Bal/test/WixToolsetTest.ManagedHost/DncHostFixture.cs
+87 -66
@@ -2,9 +2,7 @@
2
3 namespace WixToolsetTest.ManagedHost
4 {
5 - using System.IO;
5 using WixBuildTools.TestSupport;
7 - using WixToolset.Core.TestPackage;
6 using Xunit;
7
8 public class DncHostFixture
@@ -21,11 +19,13 @@ namespace WixToolsetTest.ManagedHost
19 var testEngine = new TestEngine();
20
21 var result = testEngine.RunShutdownEngine(bundleFile, baseFolder);
24 - var logMessages = result.Output;
25 - Assert.Equal("Loading .NET Core FDD bootstrapper application.", logMessages[0]);
26 - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]);
27 - Assert.Equal("EarliestCoreBA", logMessages[2]);
28 - Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]);
22 + WixAssert.CompareLineByLine(new[]
23 + {
24 + "Loading .NET Core FDD bootstrapper application.",
25 + "Creating BA thread to run asynchronously.",
26 + "EarliestCoreBA",
27 + "Shutdown,ReloadBootstrapper,0",
28 + }, result.Output.ToArray());
29 }
30 }
31
@@ -39,14 +39,17 @@ namespace WixToolsetTest.ManagedHost
39 var testEngine = new TestEngine();
40
41 var result = testEngine.RunShutdownEngine(bundleFile, baseFolder);
42 - var logMessages = result.Output;
43 - Assert.Equal("Loading .NET Core SCD bootstrapper application.", logMessages[0]);
44 - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]);
45 - Assert.Equal("EarliestCoreBA", logMessages[2]);
46 - Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]);
42 + WixAssert.CompareLineByLine(new[]
43 + {
44 + "Loading .NET Core SCD bootstrapper application.",
45 + "Creating BA thread to run asynchronously.",
46 + "EarliestCoreBA",
47 + "Shutdown,ReloadBootstrapper,0",
48 + }, result.Output.ToArray());
49 }
50 }
51
52 + [Fact]
53 public void CanLoadTrimmedSCDEarliestCoreMBA()
54 {
55 using (var fs = new DisposableFileSystem())
@@ -56,11 +59,13 @@ namespace WixToolsetTest.ManagedHost
59 var testEngine = new TestEngine();
60
61 var result = testEngine.RunShutdownEngine(bundleFile, baseFolder);
59 - var logMessages = result.Output;
60 - Assert.Equal("Loading .NET Core SCD bootstrapper application.", logMessages[0]);
61 - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]);
62 - Assert.Equal("EarliestCoreBA", logMessages[2]);
63 - Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]);
62 + WixAssert.CompareLineByLine(new[]
63 + {
64 + "Loading .NET Core SCD bootstrapper application.",
65 + "Creating BA thread to run asynchronously.",
66 + "EarliestCoreBA",
67 + "Shutdown,ReloadBootstrapper,0",
68 + }, result.Output.ToArray());
69 }
70 }
71
@@ -74,16 +79,19 @@ namespace WixToolsetTest.ManagedHost
79 var testEngine = new TestEngine();
80
81 var result = testEngine.RunReloadEngine(bundleFile, baseFolder);
77 - var logMessages = result.Output;
78 - Assert.Equal("Loading .NET Core SCD bootstrapper application.", logMessages[0]);
79 - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]);
80 - Assert.Equal("EarliestCoreBA", logMessages[2]);
81 - Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]);
82 - Assert.Equal("Loading .NET Core SCD bootstrapper application.", logMessages[4]);
83 - Assert.Equal("Reloaded 1 time(s)", logMessages[5]); // dnchost doesn't currently support unloading
84 - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[6]);
85 - Assert.Equal("EarliestCoreBA", logMessages[7]);
86 - Assert.Equal("Shutdown,Restart,0", logMessages[8]);
82 + WixAssert.CompareLineByLine(new[]
83 + {
84 + "Loading .NET Core SCD bootstrapper application.",
85 + "Creating BA thread to run asynchronously.",
86 + "EarliestCoreBA",
87 + "Shutdown,ReloadBootstrapper,0",
88 + "Loading .NET Core SCD bootstrapper application.",
89 + "Reloaded 1 time(s)", // dnchost doesn't currently support unloading
90 + "Creating BA thread to run asynchronously.",
91 + "EarliestCoreBA",
92 + "Shutdown,Restart,0",
93 +
94 + }, result.Output.ToArray());
95 }
96 }
97
@@ -97,11 +105,13 @@ namespace WixToolsetTest.ManagedHost
105 var testEngine = new TestEngine();
106
107 var result = testEngine.RunShutdownEngine(bundleFile, baseFolder);
100 - var logMessages = result.Output;
101 - Assert.Equal("Loading .NET Core FDD bootstrapper application.", logMessages[0]);
102 - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]);
103 - Assert.Equal("LatestCoreBA", logMessages[2]);
104 - Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]);
108 + WixAssert.CompareLineByLine(new[]
109 + {
110 + "Loading .NET Core FDD bootstrapper application.",
111 + "Creating BA thread to run asynchronously.",
112 + "LatestCoreBA",
113 + "Shutdown,ReloadBootstrapper,0",
114 + }, result.Output.ToArray());
115 }
116 }
117
@@ -115,16 +125,18 @@ namespace WixToolsetTest.ManagedHost
125 var testEngine = new TestEngine();
126
127 var result = testEngine.RunReloadEngine(bundleFile, baseFolder);
118 - var logMessages = result.Output;
119 - Assert.Equal("Loading .NET Core FDD bootstrapper application.", logMessages[0]);
120 - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]);
121 - Assert.Equal("LatestCoreBA", logMessages[2]);
122 - Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]);
123 - Assert.Equal("Loading .NET Core FDD bootstrapper application.", logMessages[4]);
124 - Assert.Equal("Reloaded 1 time(s)", logMessages[5]); // dnchost doesn't currently support unloading
125 - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[6]);
126 - Assert.Equal("LatestCoreBA", logMessages[7]);
127 - Assert.Equal("Shutdown,Restart,0", logMessages[8]);
128 + WixAssert.CompareLineByLine(new[]
129 + {
130 + "Loading .NET Core FDD bootstrapper application.",
131 + "Creating BA thread to run asynchronously.",
132 + "LatestCoreBA",
133 + "Shutdown,ReloadBootstrapper,0",
134 + "Loading .NET Core FDD bootstrapper application.",
135 + "Reloaded 1 time(s)", // dnchost doesn't currently support unloading
136 + "Creating BA thread to run asynchronously.",
137 + "LatestCoreBA",
138 + "Shutdown,Restart,0",
139 + }, result.Output.ToArray());
140 }
141 }
142
@@ -138,11 +150,14 @@ namespace WixToolsetTest.ManagedHost
150 var testEngine = new TestEngine();
151
152 var result = testEngine.RunShutdownEngine(bundleFile, baseFolder);
153 + WixAssert.CompareLineByLine(new[]
154 + {
155 + "Loading .NET Core SCD bootstrapper application.",
156 + "Creating BA thread to run asynchronously.",
157 + "LatestCoreBA",
158 + "Shutdown,ReloadBootstrapper,0",
159 + }, result.Output.ToArray());
160 var logMessages = result.Output;
142 - Assert.Equal("Loading .NET Core SCD bootstrapper application.", logMessages[0]);
143 - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]);
144 - Assert.Equal("LatestCoreBA", logMessages[2]);
145 - Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]);
161 }
162 }
163
@@ -156,11 +171,13 @@ namespace WixToolsetTest.ManagedHost
171 var testEngine = new TestEngine();
172
173 var result = testEngine.RunShutdownEngine(bundleFile, baseFolder);
159 - var logMessages = result.Output;
160 - Assert.Equal("Loading .NET Core SCD bootstrapper application.", logMessages[0]);
161 - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]);
162 - Assert.Equal("LatestCoreBA", logMessages[2]);
163 - Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]);
174 + WixAssert.CompareLineByLine(new[]
175 + {
176 + "Loading .NET Core SCD bootstrapper application.",
177 + "Creating BA thread to run asynchronously.",
178 + "LatestCoreBA",
179 + "Shutdown,ReloadBootstrapper,0",
180 + }, result.Output.ToArray());
181 }
182 }
183
@@ -174,16 +191,18 @@ namespace WixToolsetTest.ManagedHost
191 var testEngine = new TestEngine();
192
193 var result = testEngine.RunReloadEngine(bundleFile, baseFolder);
177 - var logMessages = result.Output;
178 - Assert.Equal("Loading .NET Core SCD bootstrapper application.", logMessages[0]);
179 - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]);
180 - Assert.Equal("LatestCoreBA", logMessages[2]);
181 - Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]);
182 - Assert.Equal("Loading .NET Core SCD bootstrapper application.", logMessages[4]);
183 - Assert.Equal("Reloaded 1 time(s)", logMessages[5]); // dnchost doesn't currently support unloading
184 - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[6]);
185 - Assert.Equal("LatestCoreBA", logMessages[7]);
186 - Assert.Equal("Shutdown,Restart,0", logMessages[8]);
194 + WixAssert.CompareLineByLine(new[]
195 + {
196 + "Loading .NET Core SCD bootstrapper application.",
197 + "Creating BA thread to run asynchronously.",
198 + "LatestCoreBA",
199 + "Shutdown,ReloadBootstrapper,0",
200 + "Loading .NET Core SCD bootstrapper application.",
201 + "Reloaded 1 time(s)", // dnchost doesn't currently support unloading
202 + "Creating BA thread to run asynchronously.",
203 + "LatestCoreBA",
204 + "Shutdown,Restart,0",
205 + }, result.Output.ToArray());
206 }
207 }
208
@@ -197,11 +216,13 @@ namespace WixToolsetTest.ManagedHost
216 var testEngine = new TestEngine();
217
218 var result = testEngine.RunShutdownEngine(bundleFile, baseFolder);
200 - var logMessages = result.Output;
201 - Assert.Equal("Loading .NET Core FDD bootstrapper application.", logMessages[0]);
202 - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]);
203 - Assert.Equal("WPFCoreBA", logMessages[2]);
204 - Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]);
219 + WixAssert.CompareLineByLine(new[]
220 + {
221 + "Loading .NET Core FDD bootstrapper application.",
222 + "Creating BA thread to run asynchronously.",
223 + "WPFCoreBA",
224 + "Shutdown,ReloadBootstrapper,0",
225 + }, result.Output.ToArray());
226 }
227 }
228 }
src/ext/Bal/test/WixToolsetTest.ManagedHost/MbaHostFixture.cs
+36 -30
@@ -2,9 +2,7 @@
2
3 namespace WixToolsetTest.ManagedHost
4 {
5 - using System.IO;
5 using WixBuildTools.TestSupport;
7 - using WixToolset.Core.TestPackage;
6 using Xunit;
7
8 public class MbaHostFixture
@@ -21,11 +19,13 @@ namespace WixToolsetTest.ManagedHost
19 var testEngine = new TestEngine();
20
21 var result = testEngine.RunShutdownEngine(bundleFile, baseFolder);
24 - var logMessages = result.Output;
25 - Assert.Equal("Loading managed bootstrapper application.", logMessages[0]);
26 - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]);
27 - Assert.Equal("FullFramework2BA", logMessages[2]);
28 - Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]);
22 + WixAssert.CompareLineByLine(new[]
23 + {
24 + "Loading managed bootstrapper application.",
25 + "Creating BA thread to run asynchronously.",
26 + "FullFramework2BA",
27 + "Shutdown,ReloadBootstrapper,0",
28 + }, result.Output.ToArray());
29 }
30 }
31
@@ -39,11 +39,13 @@ namespace WixToolsetTest.ManagedHost
39 var testEngine = new TestEngine();
40
41 var result = testEngine.RunShutdownEngine(bundleFile, baseFolder);
42 - var logMessages = result.Output;
43 - Assert.Equal("Loading managed bootstrapper application.", logMessages[0]);
44 - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]);
45 - Assert.Equal("FullFramework4BA", logMessages[2]);
46 - Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]);
42 + WixAssert.CompareLineByLine(new[]
43 + {
44 + "Loading managed bootstrapper application.",
45 + "Creating BA thread to run asynchronously.",
46 + "FullFramework4BA",
47 + "Shutdown,ReloadBootstrapper,0",
48 + }, result.Output.ToArray());
49 }
50 }
51
@@ -57,15 +59,17 @@ namespace WixToolsetTest.ManagedHost
59 var testEngine = new TestEngine();
60
61 var result = testEngine.RunReloadEngine(bundleFile, baseFolder);
60 - var logMessages = result.Output;
61 - Assert.Equal("Loading managed bootstrapper application.", logMessages[0]);
62 - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]);
63 - Assert.Equal("FullFramework2BA", logMessages[2]);
64 - Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]);
65 - Assert.Equal("Loading managed bootstrapper application.", logMessages[4]);
66 - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[5]);
67 - Assert.Equal("FullFramework2BA", logMessages[6]);
68 - Assert.Equal("Shutdown,Restart,0", logMessages[7]);
62 + WixAssert.CompareLineByLine(new[]
63 + {
64 + "Loading managed bootstrapper application.",
65 + "Creating BA thread to run asynchronously.",
66 + "FullFramework2BA",
67 + "Shutdown,ReloadBootstrapper,0",
68 + "Loading managed bootstrapper application.",
69 + "Creating BA thread to run asynchronously.",
70 + "FullFramework2BA",
71 + "Shutdown,Restart,0",
72 + }, result.Output.ToArray());
73 }
74 }
75
@@ -79,15 +83,17 @@ namespace WixToolsetTest.ManagedHost
83 var testEngine = new TestEngine();
84
85 var result = testEngine.RunReloadEngine(bundleFile, baseFolder);
82 - var logMessages = result.Output;
83 - Assert.Equal("Loading managed bootstrapper application.", logMessages[0]);
84 - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]);
85 - Assert.Equal("FullFramework4BA", logMessages[2]);
86 - Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]);
87 - Assert.Equal("Loading managed bootstrapper application.", logMessages[4]);
88 - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[5]);
89 - Assert.Equal("FullFramework4BA", logMessages[6]);
90 - Assert.Equal("Shutdown,Restart,0", logMessages[7]);
86 + WixAssert.CompareLineByLine(new[]
87 + {
88 + "Loading managed bootstrapper application.",
89 + "Creating BA thread to run asynchronously.",
90 + "FullFramework4BA",
91 + "Shutdown,ReloadBootstrapper,0",
92 + "Loading managed bootstrapper application.",
93 + "Creating BA thread to run asynchronously.",
94 + "FullFramework4BA",
95 + "Shutdown,Restart,0",
96 + }, result.Output.ToArray());
97 }
98 }
99 }
src/ext/Bal/test/WixToolsetTest.ManagedHost/TestEngine.cs
+2 -1
@@ -2,6 +2,7 @@
2
3 namespace WixToolsetTest.ManagedHost
4 {
5 + using System;
6 using System.Collections.Generic;
7 using System.Diagnostics;
8 using System.IO;
@@ -41,7 +42,7 @@ namespace WixToolsetTest.ManagedHost
42 {
43 var startInfo = new ProcessStartInfo(executablePath)
44 {
44 - Arguments = string.Join(' ', arguments),
45 + Arguments = String.Join(' ', arguments),
46 CreateNoWindow = true,
47 RedirectStandardError = true,
48 RedirectStandardOutput = true,
src/ext/Bal/test/examples/Directory.Build.props
+2 -1
@@ -2,5 +2,6 @@
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 <Project>
4 <Import Project="$(MsbuildThisFileDirectory)..\..\Directory.Build.props" />
5 - <Import Project="Wix.Build.props" Condition=" '$(MSBuildProjectExtension)'=='.wixproj' " />
5 + <Import Project="Directory.csproj.props" Condition=" '$(MSBuildProjectExtension)'=='.csproj' " />
6 + <Import Project="Directory.wixproj.props" Condition=" '$(MSBuildProjectExtension)'=='.wixproj' " />
7 </Project>
src/ext/Bal/test/examples/Directory.Build.targets
+2 -1
@@ -2,5 +2,6 @@
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 <Project>
4 <Import Project="$(MsbuildThisFileDirectory)..\..\..\..\Directory.Build.targets" />
5 - <Import Project="Wix.Build.targets" Condition=" '$(MSBuildProjectExtension)'=='.wixproj' " />
5 + <Import Project="Directory.wixproj.targets" Condition=" '$(MSBuildProjectExtension)'=='.wixproj' " />
6 + <Import Project="DncBA.targets" Condition=" '$(IsDncBA)'=='true' " />
7 </Project>
src/ext/Bal/test/examples/Directory.csproj.props new
+5
@@ -0,0 +1,5 @@
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 +<Project>
4 + <Import Project="$(MsbuildThisFileDirectory)..\..\WixToolset.Dnc.HostGenerator\build\WixToolset.Dnc.HostGenerator.props" />
5 +</Project>
src/ext/Bal/test/examples/Directory.wixproj.props renamed
src/ext/Bal/test/examples/Directory.wixproj.targets renamed
src/ext/Bal/test/examples/DncBA.targets new
+19
@@ -0,0 +1,19 @@
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 +<Project>
4 + <Import Project="$(MsbuildThisFileDirectory)..\..\WixToolset.Dnc.HostGenerator\build\WixToolset.Dnc.HostGenerator.targets" />
5 +
6 + <PropertyGroup>
7 + <ILLinkTreatWarningsAsErrors>false</ILLinkTreatWarningsAsErrors>
8 + </PropertyGroup>
9 +
10 + <ItemGroup>
11 + <ProjectReference Include="$(MsbuildThisFileDirectory)..\..\WixToolset.Dnc.HostGenerator\WixToolset.Dnc.HostGenerator.csproj"
12 + OutputItemType="Analyzer"
13 + ReferenceOutputAssembly="false" />
14 + </ItemGroup>
15 +
16 + <ItemGroup>
17 + <PackageReference Include="WixToolset.Mba.Core" />
18 + </ItemGroup>
19 +</Project>
src/ext/Bal/test/examples/EarliestCoreMBA/Example.EarliestCoreMBA.csproj
+1 -9
@@ -3,15 +3,7 @@
3 <PropertyGroup>
4 <TargetFramework>netcoreapp3.1</TargetFramework>
5 <RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
6 - <EnableDynamicLoading>true</EnableDynamicLoading>
6 + <IsDncBA>true</IsDncBA>
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="WixToolset.Mba.Core" />
16 - </ItemGroup>
9 </Project>
src/ext/Bal/test/examples/LatestCoreMBA/Example.LatestCoreMBA.csproj
+1 -12
@@ -3,18 +3,7 @@
3 <PropertyGroup>
4 <TargetFramework>net5.0</TargetFramework>
5 <RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
6 - <EnableDynamicLoading>true</EnableDynamicLoading>
6 + <IsDncBA>true</IsDncBA>
7 <Description>Latest .NET Core MBA</Description>
8 </PropertyGroup>
9 -
10 - <ItemGroup>
11 - <TrimmerRootAssembly Include="System.Diagnostics.Tools" />
12 - <TrimmerRootAssembly Include="System.Runtime" />
13 - <TrimmerRootAssembly Include="System.Runtime.InteropServices" />
14 - <TrimmerRootAssembly Include="System.Runtime.Loader" />
15 - </ItemGroup>
16 -
17 - <ItemGroup>
18 - <PackageReference Include="WixToolset.Mba.Core" />
19 - </ItemGroup>
9 </Project>
src/ext/Bal/test/examples/WPFCoreMBA/Example.WPFCoreMBA.csproj
+1 -15
@@ -3,22 +3,8 @@
3 <PropertyGroup>
4 <TargetFramework>net5.0-windows</TargetFramework>
5 <RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
6 - <EnableDynamicLoading>true</EnableDynamicLoading>
6 + <IsDncBA>true</IsDncBA>
7 <Description>WPF .NET Core MBA</Description>
8 <UseWPF>true</UseWPF>
9 </PropertyGroup>
10 -
11 - <ItemGroup>
12 - <PackageReference Include="WixToolset.Mba.Core" />
13 - </ItemGroup>
14 -
15 - <Target Name="GitVersion">
16 - <PropertyGroup>
17 - <GitBaseVersionMajor>42</GitBaseVersionMajor>
18 - <GitBaseVersionMinor>42</GitBaseVersionMinor>
19 - <GitBaseVersionPatch>42</GitBaseVersionPatch>
20 - <GitCommits>42</GitCommits>
21 - <GitSha>abc123def456</GitSha>
22 - </PropertyGroup>
23 - </Target>
10 </Project>
src/ext/Bal/test/examples/examples.proj
+4 -3
@@ -17,14 +17,15 @@
17 <ItemGroup>
18 <CoreMBAProject Include="$(EarliestCoreMBAProjectPath)">
19 <PublishPath>$(MBAPublishPath)Example.EarliestCoreMBA</PublishPath>
20 + <TrimMode>CopyUsed</TrimMode>
21 </CoreMBAProject>
22 <CoreMBAProject Include="$(LatestCoreMBAProjectPath)">
23 <PublishPath>$(MBAPublishPath)Example.LatestCoreMBA</PublishPath>
24 + <TrimMode>Link</TrimMode>
25 </CoreMBAProject>
26 <CoreMBAProject Include="$(WPFCoreMBAProjectPath)">
27 <PublishPath>$(MBAPublishPath)Example.WPFCoreMBA</PublishPath>
28 <SkipSCD>true</SkipSCD>
27 - <SkipTrimmedSCD>true</SkipTrimmedSCD>
29 </CoreMBAProject>
30
31 <FullMBAProject Include="$(FullFramework2MBAProjectPath)" />
@@ -38,8 +39,8 @@
39 Condition="'%(CoreMBAProject.SkipFDD)'==''" />
40 <Exec Command='dotnet publish -o "%(CoreMBAProject.PublishPath)\scd" -r win-x86 -c $(Configuration) --self-contained true "%(CoreMBAProject.Identity)"'
41 Condition="'%(CoreMBAProject.SkipSCD)'==''" />
41 - <Exec Command='dotnet publish -o "%(CoreMBAProject.PublishPath)\trimmedscd" -r win-x86 -c $(Configuration) --self-contained true -p:PublishTrimmed=true "%(CoreMBAProject.Identity)"'
42 - Condition="'%(CoreMBAProject.SkipTrimmedSCD)'==''" />
42 + <Exec Command='dotnet publish -o "%(CoreMBAProject.PublishPath)\trimmedscd" -r win-x86 -c $(Configuration) --self-contained true -p:PublishTrimmed=true -p:TrimMode=%(CoreMBAProject.TrimMode) "%(CoreMBAProject.Identity)"'
43 + Condition="'%(CoreMBAProject.TrimMode)'!=''" />
44 </Target>
45
46 <Target Name="Build" DependsOnTargets="PublishCoreExamples">
src/ext/Bal/wixext/WixToolset.Bal.wixext.nuspec
+1 -1
@@ -7,7 +7,7 @@
7 <owners>$authors$</owners>
8 <icon>wix-white-bg.png</icon>
9 <license type="expression">MS-RL</license>
10 - <projectUrl>https://github.com/wixtoolset/Bal.wixext</projectUrl>
10 + <projectUrl>$projectUrl$</projectUrl>
11 <requireLicenseAcceptance>false</requireLicenseAcceptance>
12 <title>$title$</title>
13 <description>$description$</description>
src/ext/Bal/wixlib/BalExtension_platform.wxi
-1
@@ -8,7 +8,6 @@
8 <BootstrapperApplication Id="WixDotNetCoreBootstrapperApplicationHost$(var.Suffix)">
9 <BootstrapperApplicationDll Id="WixDotNetCoreBootstrapperApplicationHost" SourceFile="!(bindpath.$(var.platform))\dnchost.dll" />
10 <Payload SourceFile="!(bindpath.$(var.platform))\wixstdba.dll" Name="dncpreq.dll" />
11 - <PayloadGroupRef Id="WixDotNetCoreBootstrapperApplicationHostManagedPayloads" />
11 </BootstrapperApplication>
12 </Fragment>
13
src/ext/Bal/wixlib/Dnc.wxs
-5
@@ -5,11 +5,6 @@
5 <!--
6 Dnc.wxs - .NET Core BA resources.
7 -->
8 - <Fragment>
9 - <PayloadGroup Id="WixDotNetCoreBootstrapperApplicationHostManagedPayloads">
10 - <Payload SourceFile="WixToolset.Dnc.Host.dll" />
11 - </PayloadGroup>
12 - </Fragment>
8 <Fragment>
9 <PayloadGroup Id="DncPreqStandardPayloads">
10 <Payload Name="mbapreq.thm" SourceFile="!(wix.DncPreqbaThemeXml=SourceDir\dncpreq.thm)" />
src/internal/SetBuildNumber/Directory.Packages.props.pp
+5
@@ -21,6 +21,7 @@
21 <PackageVersion Include="WixToolset.Extensibility" Version="{packageversion}" />
22
23 <PackageVersion Include="WixToolset.Burn" Version="{packageversion}" />
24 + <PackageVersion Include="WixToolset.Dnc.HostGenerator" Version="{packageversion}" />
25
26 <PackageVersion Include="WixToolset.Core" Version="{packageversion}" />
27 <PackageVersion Include="WixToolset.Core.Burn" Version="{packageversion}" />
@@ -45,6 +46,10 @@
46 <PackageVersion Include="System.Text.Encoding.CodePages" Version="4.6.0" />
47
48 <PackageVersion Include="Microsoft.AspNetCore.Owin" Version="3.1.13" />
49 + <PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3" />
50 + <PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="3.8.0" />
51 + <PackageVersion Include="Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing.XUnit" Version="1.1.1" />
52 + <PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.8.0" />
53 <PackageVersion Include="Microsoft.VisualStudio.Setup.Configuration.Native" Version="1.14.114" />
54 <PackageVersion Include="Microsoft.Win32.Registry" Version="4.7.0" />
55
src/test/burn/TestBA/TestBA.csproj
+4
@@ -21,4 +21,8 @@
21 <ItemGroup>
22 <PackageReference Include="WixToolset.Mba.Core" />
23 </ItemGroup>
24 +
25 + <ItemGroup Condition=" '$(TargetFrameworkIdentifier)'!='.NETFramework' ">
26 + <PackageReference Include="WixToolset.Dnc.HostGenerator" />
27 + </ItemGroup>
28 </Project>
src/test/burn/TestBA/TestBA_x64.csproj
+4
@@ -21,4 +21,8 @@
21 <ItemGroup>
22 <PackageReference Include="WixToolset.Mba.Core" />
23 </ItemGroup>
24 +
25 + <ItemGroup Condition=" '$(TargetFrameworkIdentifier)'!='.NETFramework' ">
26 + <PackageReference Include="WixToolset.Dnc.HostGenerator" />
27 + </ItemGroup>
28 </Project>
src/test/burn/TestData/TestBA/TestBAWixlib/testbawixlib.wixproj
+1 -1
@@ -7,7 +7,7 @@
7 </PropertyGroup>
8 <ItemGroup>
9 <BindInputPaths Include="$(BaseOutputPath)$(Configuration)\net35\win-x86" BindName="net2x86" />
10 - <BindInputPaths Include="$(BaseOutputPath)$(Configuration)\net45\win-x86" BindName="net4x86" />
10 + <BindInputPaths Include="$(BaseOutputPath)$(Configuration)\net472\win-x86" BindName="net4x86" />
11 <BindInputPaths Include="$(BaseOutputPath)$(Configuration)\net5.0-windows\win-x86" BindName="dnc5x86" />
12 </ItemGroup>
13 <ItemGroup>
src/test/burn/TestData/TestBA/TestBAWixlib_x64/testbawixlib_x64.wixproj
+1 -1
@@ -8,7 +8,7 @@
8 </PropertyGroup>
9 <ItemGroup>
10 <BindInputPaths Include="$(BaseOutputPath)$(Configuration)\net35\win-x64" BindName="net2x64" />
11 - <BindInputPaths Include="$(BaseOutputPath)$(Configuration)\net45\win-x64" BindName="net4x64" />
11 + <BindInputPaths Include="$(BaseOutputPath)$(Configuration)\net472\win-x64" BindName="net4x64" />
12 <BindInputPaths Include="$(BaseOutputPath)$(Configuration)\net5.0-windows\win-x64" BindName="dnc5x64" />
13 </ItemGroup>
14 <ItemGroup>
src/test/burn/WixToolset.WixBA/WixToolset.WixBA.csproj
+7 -3
@@ -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. -->
3 <Project Sdk="Microsoft.NET.Sdk">
4 <PropertyGroup>
5 - <TargetFrameworks>net45;net5.0-windows</TargetFrameworks>
5 + <TargetFrameworks>net472;net5.0-windows</TargetFrameworks>
6 <AssemblyName>WixToolset.WixBA</AssemblyName>
7 <RootNamespace>WixToolset.WixBA</RootNamespace>
8 <DebugType>embedded</DebugType>
@@ -19,14 +19,14 @@
19 <!-- https://stackoverflow.com/questions/58844785/how-to-reference-system-windows-forms-in-net-core-3-0-for-wpf-apps -->
20 <UseWindowsForms>true</UseWindowsForms>
21 </PropertyGroup>
22 - <ItemGroup Condition="'$(TargetFramework)'=='net45'">
22 + <ItemGroup Condition=" '$(TargetFrameworkIdentifier)'=='.NETFramework' ">
23 <Content Include="WixBA.BootstrapperCore.config" CopyToOutputDirectory="PreserveNewest" />
24 </ItemGroup>
25 <ItemGroup>
26 <Resource Include="Resources\logo-white-hollow.png" />
27 <Resource Include="Resources\logo-black-hollow.png" />
28 </ItemGroup>
29 - <ItemGroup Condition="'$(TargetFramework)'=='net45'">
29 + <ItemGroup Condition=" '$(TargetFrameworkIdentifier)'=='.NETFramework' ">
30 <Reference Include="PresentationCore" />
31 <Reference Include="PresentationFramework" />
32 <Reference Include="System.Windows.Forms" />
@@ -37,4 +37,8 @@
37 <ItemGroup>
38 <PackageReference Include="WixToolset.Mba.Core" />
39 </ItemGroup>
40 +
41 + <ItemGroup Condition=" '$(TargetFrameworkIdentifier)'!='.NETFramework' ">
42 + <PackageReference Include="WixToolset.Dnc.HostGenerator" />
43 + </ItemGroup>
44 </Project>
\ No newline at end of file
src/test/burn/WixToolset.WixBA/WixToolset.WixBA_x64.csproj
+7 -3
@@ -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. -->
3 <Project Sdk="Microsoft.NET.Sdk">
4 <PropertyGroup>
5 - <TargetFrameworks>net45;net5.0-windows</TargetFrameworks>
5 + <TargetFrameworks>net472;net5.0-windows</TargetFrameworks>
6 <AssemblyName>WixToolset.WixBA</AssemblyName>
7 <RootNamespace>WixToolset.WixBA</RootNamespace>
8 <DebugType>embedded</DebugType>
@@ -19,14 +19,14 @@
19 <!-- https://stackoverflow.com/questions/58844785/how-to-reference-system-windows-forms-in-net-core-3-0-for-wpf-apps -->
20 <UseWindowsForms>true</UseWindowsForms>
21 </PropertyGroup>
22 - <ItemGroup Condition="'$(TargetFramework)'=='net45'">
22 + <ItemGroup Condition=" '$(TargetFrameworkIdentifier)'=='.NETFramework' ">
23 <Content Include="WixBA.BootstrapperCore.config" CopyToOutputDirectory="PreserveNewest" />
24 </ItemGroup>
25 <ItemGroup>
26 <Resource Include="Resources\logo-white-hollow.png" />
27 <Resource Include="Resources\logo-black-hollow.png" />
28 </ItemGroup>
29 - <ItemGroup Condition="'$(TargetFramework)'=='net45'">
29 + <ItemGroup Condition=" '$(TargetFrameworkIdentifier)'=='.NETFramework' ">
30 <Reference Include="PresentationCore" />
31 <Reference Include="PresentationFramework" />
32 <Reference Include="System.Windows.Forms" />
@@ -37,4 +37,8 @@
37 <ItemGroup>
38 <PackageReference Include="WixToolset.Mba.Core" />
39 </ItemGroup>
40 +
41 + <ItemGroup Condition=" '$(TargetFrameworkIdentifier)'!='.NETFramework' ">
42 + <PackageReference Include="WixToolset.Dnc.HostGenerator" />
43 + </ItemGroup>
44 </Project>
\ No newline at end of file
src/testresultfilelist.txt
+1
@@ -12,6 +12,7 @@ build/logs/TestResults/WixToolsetTest.Core.trx
12 build/logs/TestResults/WixToolsetTest.Core.Burn.trx
13 build/logs/TestResults/WixToolsetTest.Core.Native.trx
14 build/logs/TestResults/WixToolsetTest.CoreIntegration.trx
15 +build/logs/TestResults/WixToolsetTest.Dnc.HostGenerator.trx
16 build/logs/TestResults/WixToolsetTest.Heat.trx
17 build/logs/TestResults/WixToolsetTest.Mba.Core.trx
18 build/logs/TestResults/WixToolsetTest.Sdk.trx
src/wix/WixToolset.Sdk/WixToolset.Sdk.csproj
-2
@@ -4,12 +4,10 @@
4 <Project Sdk="Microsoft.NET.Sdk">
5 <PropertyGroup>
6 <TargetFramework>netcoreapp3.1</TargetFramework>
7 - <IncludeBuildOutput>false</IncludeBuildOutput>
7 <Description>WiX Toolset MSBuild integration</Description>
8 <PublishDir>$(OutputPath)publish\WixToolset.Sdk\</PublishDir>
9 <NuspecFile>$(MSBuildThisFileName).nuspec</NuspecFile>
10 <NuspecBasePath>$(PublishDir)</NuspecBasePath>
12 - <NuspecProperties>Id=$(MSBuildThisFileName);Authors=$(Authors);Copyright=$(Copyright);Description=$(Description)</NuspecProperties>
11 </PropertyGroup>
12
13 <ItemGroup>