From 57fd164d56466a52854e825afd5fdc2b6b97f12a Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Tue, 19 Apr 2022 17:15:05 -0500 Subject: Replace Dnc.Host with Dnc.HostGenerator to support linker trimming. --- src/clean.cmd | 1 + src/ext/Bal/Bal.wixext.sln | 52 ++++--- .../BootstrapperApplicationFactory.cs | 89 ------------ .../DnchostAssemblyLoadContext.cs | 58 -------- src/ext/Bal/WixToolset.Dnc.Host/Exceptions.cs | 145 ------------------- .../IBootstrapperApplicationFactory.cs | 16 --- src/ext/Bal/WixToolset.Dnc.Host/NativeMethods.cs | 18 --- .../WixToolset.Dnc.Host/WixToolset.Dnc.Host.csproj | 39 ------ .../DncHostGenerator.cs | 127 +++++++++++++++++ .../WixToolset.Dnc.HostGenerator.csproj | 27 ++++ .../WixToolset.Dnc.HostGenerator.nuspec | 23 ++++ .../build/WixToolset.Dnc.HostGenerator.props | 10 ++ .../build/WixToolset.Dnc.HostGenerator.targets | 11 ++ src/ext/Bal/bal.cmd | 7 +- src/ext/Bal/dnchost/dnchost.cpp | 5 +- src/ext/Bal/dnchost/dnchost.h | 1 - src/ext/Bal/dnchost/dnchost.vcxproj | 8 -- src/ext/Bal/dnchost/dncutil.cpp | 42 ++++-- src/ext/Bal/dnchost/dncutil.h | 5 +- src/ext/Bal/dnchost/precomp.h | 1 - .../CSharpSourceGeneratorVerifier.cs | 45 ++++++ .../DncHostGeneratorTests.cs | 88 ++++++++++++ .../WixToolsetTest.Dnc.HostGenerator.csproj | 27 ++++ .../WixToolsetTest.ManagedHost/DncHostFixture.cs | 153 ++++++++++++--------- .../WixToolsetTest.ManagedHost/MbaHostFixture.cs | 66 +++++---- .../test/WixToolsetTest.ManagedHost/TestEngine.cs | 3 +- src/ext/Bal/test/examples/Directory.Build.props | 3 +- src/ext/Bal/test/examples/Directory.Build.targets | 3 +- src/ext/Bal/test/examples/Directory.csproj.props | 5 + src/ext/Bal/test/examples/Directory.wixproj.props | 11 ++ .../Bal/test/examples/Directory.wixproj.targets | 8 ++ src/ext/Bal/test/examples/DncBA.targets | 19 +++ .../EarliestCoreMBA/Example.EarliestCoreMBA.csproj | 10 +- .../LatestCoreMBA/Example.LatestCoreMBA.csproj | 13 +- .../examples/WPFCoreMBA/Example.WPFCoreMBA.csproj | 16 +-- src/ext/Bal/test/examples/Wix.Build.props | 11 -- src/ext/Bal/test/examples/Wix.Build.targets | 8 -- src/ext/Bal/test/examples/examples.proj | 7 +- src/ext/Bal/wixext/WixToolset.Bal.wixext.nuspec | 2 +- src/ext/Bal/wixlib/BalExtension_platform.wxi | 1 - src/ext/Bal/wixlib/Dnc.wxs | 5 - .../SetBuildNumber/Directory.Packages.props.pp | 5 + src/test/burn/TestBA/TestBA.csproj | 4 + src/test/burn/TestBA/TestBA_x64.csproj | 4 + .../TestBA/TestBAWixlib/testbawixlib.wixproj | 2 +- .../TestBAWixlib_x64/testbawixlib_x64.wixproj | 2 +- .../burn/WixToolset.WixBA/WixToolset.WixBA.csproj | 10 +- .../WixToolset.WixBA/WixToolset.WixBA_x64.csproj | 10 +- src/testresultfilelist.txt | 1 + src/wix/WixToolset.Sdk/WixToolset.Sdk.csproj | 2 - 50 files changed, 645 insertions(+), 584 deletions(-) delete mode 100644 src/ext/Bal/WixToolset.Dnc.Host/BootstrapperApplicationFactory.cs delete mode 100644 src/ext/Bal/WixToolset.Dnc.Host/DnchostAssemblyLoadContext.cs delete mode 100644 src/ext/Bal/WixToolset.Dnc.Host/Exceptions.cs delete mode 100644 src/ext/Bal/WixToolset.Dnc.Host/IBootstrapperApplicationFactory.cs delete mode 100644 src/ext/Bal/WixToolset.Dnc.Host/NativeMethods.cs delete mode 100644 src/ext/Bal/WixToolset.Dnc.Host/WixToolset.Dnc.Host.csproj create mode 100644 src/ext/Bal/WixToolset.Dnc.HostGenerator/DncHostGenerator.cs create mode 100644 src/ext/Bal/WixToolset.Dnc.HostGenerator/WixToolset.Dnc.HostGenerator.csproj create mode 100644 src/ext/Bal/WixToolset.Dnc.HostGenerator/WixToolset.Dnc.HostGenerator.nuspec create mode 100644 src/ext/Bal/WixToolset.Dnc.HostGenerator/build/WixToolset.Dnc.HostGenerator.props create mode 100644 src/ext/Bal/WixToolset.Dnc.HostGenerator/build/WixToolset.Dnc.HostGenerator.targets create mode 100644 src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/CSharpSourceGeneratorVerifier.cs create mode 100644 src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/DncHostGeneratorTests.cs create mode 100644 src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/WixToolsetTest.Dnc.HostGenerator.csproj create mode 100644 src/ext/Bal/test/examples/Directory.csproj.props create mode 100644 src/ext/Bal/test/examples/Directory.wixproj.props create mode 100644 src/ext/Bal/test/examples/Directory.wixproj.targets create mode 100644 src/ext/Bal/test/examples/DncBA.targets delete mode 100644 src/ext/Bal/test/examples/Wix.Build.props delete mode 100644 src/ext/Bal/test/examples/Wix.Build.targets diff --git a/src/clean.cmd b/src/clean.cmd index 5bedadbd..bd44bed4 100644 --- a/src/clean.cmd +++ b/src/clean.cmd @@ -27,6 +27,7 @@ if exist "%_NUGET_CACHE%\wixtoolset.core.testpackage" rd /s/q "%_NUGET_CACHE%\wi if exist "%_NUGET_CACHE%\wixtoolset.core.windowsinstaller" rd /s/q "%_NUGET_CACHE%\wixtoolset.core.windowsinstaller" if exist "%_NUGET_CACHE%\wixtoolset.data" rd /s/q "%_NUGET_CACHE%\wixtoolset.data" if exist "%_NUGET_CACHE%\wixtoolset.dependency.wixext" rd /s/q "%_NUGET_CACHE%\wixtoolset.dependency.wixext" +if exist "%_NUGET_CACHE%\wixtoolset.dnc.hostgenerator" rd /s/q "%_NUGET_CACHE%\wixtoolset.dnc.hostgenerator" if exist "%_NUGET_CACHE%\wixtoolset.dtf.compression" rd /s/q "%_NUGET_CACHE%\wixtoolset.dtf.compression" if exist "%_NUGET_CACHE%\wixtoolset.dtf.compression.cab" rd /s/q "%_NUGET_CACHE%\wixtoolset.dtf.compression.cab" if exist "%_NUGET_CACHE%\wixtoolset.dtf.customaction" rd /s/q "%_NUGET_CACHE%\wixtoolset.dtf.customaction" diff --git a/src/ext/Bal/Bal.wixext.sln b/src/ext/Bal/Bal.wixext.sln index ee14dd97..dbb70a82 100644 --- a/src/ext/Bal/Bal.wixext.sln +++ b/src/ext/Bal/Bal.wixext.sln @@ -15,7 +15,7 @@ Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "bal", "wixlib\bal.wixproj", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.Bal.wixext", "wixext\WixToolset.Bal.wixext.csproj", "{BF720A63-9D7B-456E-B60C-8122852D9FED}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.Dnc.Host", "WixToolset.Dnc.Host\WixToolset.Dnc.Host.csproj", "{0D780900-C2FF-4FA2-8CB5-8A19768724C5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.Dnc.HostGenerator", "WixToolset.Dnc.HostGenerator\WixToolset.Dnc.HostGenerator.csproj", "{D6A58B36-D47E-4020-A130-58B0CEAF01A2}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.Mba.Host", "WixToolset.Mba.Host\WixToolset.Mba.Host.csproj", "{F2BA1935-70FA-4156-B161-FD03850B4FAA}" EndProject @@ -23,6 +23,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.FullFramework2MBA", EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Example.TestEngine", "test\examples\TestEngine\Example.TestEngine.vcxproj", "{3D44B67D-A475-49BA-8310-E39F6C117CC9}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolsetTest.Dnc.HostGenerator", "test\WixToolsetTest.Dnc.HostGenerator\WixToolsetTest.Dnc.HostGenerator.csproj", "{38D80FC7-EBD4-4902-A114-C93AA75CFCA0}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolsetTest.ManagedHost", "test\WixToolsetTest.ManagedHost\WixToolsetTest.ManagedHost.csproj", "{FED9D707-E5C3-4867-87B0-FABDB5EB0823}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.FullFramework4MBA", "test\examples\FullFramework4MBA\Example.FullFramework4MBA.csproj", "{44297646-706D-4508-8E96-1B35B109694C}" @@ -125,22 +127,22 @@ Global {BF720A63-9D7B-456E-B60C-8122852D9FED}.Release|x64.Build.0 = Release|Any CPU {BF720A63-9D7B-456E-B60C-8122852D9FED}.Release|x86.ActiveCfg = Release|Any CPU {BF720A63-9D7B-456E-B60C-8122852D9FED}.Release|x86.Build.0 = Release|Any CPU - {0D780900-C2FF-4FA2-8CB5-8A19768724C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0D780900-C2FF-4FA2-8CB5-8A19768724C5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0D780900-C2FF-4FA2-8CB5-8A19768724C5}.Debug|ARM64.ActiveCfg = Debug|Any CPU - {0D780900-C2FF-4FA2-8CB5-8A19768724C5}.Debug|ARM64.Build.0 = Debug|Any CPU - {0D780900-C2FF-4FA2-8CB5-8A19768724C5}.Debug|x64.ActiveCfg = Debug|Any CPU - {0D780900-C2FF-4FA2-8CB5-8A19768724C5}.Debug|x64.Build.0 = Debug|Any CPU - {0D780900-C2FF-4FA2-8CB5-8A19768724C5}.Debug|x86.ActiveCfg = Debug|Any CPU - {0D780900-C2FF-4FA2-8CB5-8A19768724C5}.Debug|x86.Build.0 = Debug|Any CPU - {0D780900-C2FF-4FA2-8CB5-8A19768724C5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0D780900-C2FF-4FA2-8CB5-8A19768724C5}.Release|Any CPU.Build.0 = Release|Any CPU - {0D780900-C2FF-4FA2-8CB5-8A19768724C5}.Release|ARM64.ActiveCfg = Release|Any CPU - {0D780900-C2FF-4FA2-8CB5-8A19768724C5}.Release|ARM64.Build.0 = Release|Any CPU - {0D780900-C2FF-4FA2-8CB5-8A19768724C5}.Release|x64.ActiveCfg = Release|Any CPU - {0D780900-C2FF-4FA2-8CB5-8A19768724C5}.Release|x64.Build.0 = Release|Any CPU - {0D780900-C2FF-4FA2-8CB5-8A19768724C5}.Release|x86.ActiveCfg = Release|Any CPU - {0D780900-C2FF-4FA2-8CB5-8A19768724C5}.Release|x86.Build.0 = Release|Any CPU + {D6A58B36-D47E-4020-A130-58B0CEAF01A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D6A58B36-D47E-4020-A130-58B0CEAF01A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D6A58B36-D47E-4020-A130-58B0CEAF01A2}.Debug|ARM64.ActiveCfg = Debug|AnyCPU + {D6A58B36-D47E-4020-A130-58B0CEAF01A2}.Debug|ARM64.Build.0 = Debug|AnyCPU + {D6A58B36-D47E-4020-A130-58B0CEAF01A2}.Debug|x64.ActiveCfg = Debug|AnyCPU + {D6A58B36-D47E-4020-A130-58B0CEAF01A2}.Debug|x64.Build.0 = Debug|AnyCPU + {D6A58B36-D47E-4020-A130-58B0CEAF01A2}.Debug|x86.ActiveCfg = Debug|AnyCPU + {D6A58B36-D47E-4020-A130-58B0CEAF01A2}.Debug|x86.Build.0 = Debug|AnyCPU + {D6A58B36-D47E-4020-A130-58B0CEAF01A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D6A58B36-D47E-4020-A130-58B0CEAF01A2}.Release|Any CPU.Build.0 = Release|Any CPU + {D6A58B36-D47E-4020-A130-58B0CEAF01A2}.Release|ARM64.ActiveCfg = Release|AnyCPU + {D6A58B36-D47E-4020-A130-58B0CEAF01A2}.Release|ARM64.Build.0 = Release|AnyCPU + {D6A58B36-D47E-4020-A130-58B0CEAF01A2}.Release|x64.ActiveCfg = Release|AnyCPU + {D6A58B36-D47E-4020-A130-58B0CEAF01A2}.Release|x64.Build.0 = Release|AnyCPU + {D6A58B36-D47E-4020-A130-58B0CEAF01A2}.Release|x86.ActiveCfg = Release|AnyCPU + {D6A58B36-D47E-4020-A130-58B0CEAF01A2}.Release|x86.Build.0 = Release|AnyCPU {F2BA1935-70FA-4156-B161-FD03850B4FAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F2BA1935-70FA-4156-B161-FD03850B4FAA}.Debug|Any CPU.Build.0 = Debug|Any CPU {F2BA1935-70FA-4156-B161-FD03850B4FAA}.Debug|ARM64.ActiveCfg = Debug|Any CPU @@ -189,6 +191,22 @@ Global {3D44B67D-A475-49BA-8310-E39F6C117CC9}.Release|x64.Build.0 = Release|x64 {3D44B67D-A475-49BA-8310-E39F6C117CC9}.Release|x86.ActiveCfg = Release|Win32 {3D44B67D-A475-49BA-8310-E39F6C117CC9}.Release|x86.Build.0 = Release|Win32 + {38D80FC7-EBD4-4902-A114-C93AA75CFCA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {38D80FC7-EBD4-4902-A114-C93AA75CFCA0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {38D80FC7-EBD4-4902-A114-C93AA75CFCA0}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {38D80FC7-EBD4-4902-A114-C93AA75CFCA0}.Debug|ARM64.Build.0 = Debug|Any CPU + {38D80FC7-EBD4-4902-A114-C93AA75CFCA0}.Debug|x64.ActiveCfg = Debug|Any CPU + {38D80FC7-EBD4-4902-A114-C93AA75CFCA0}.Debug|x64.Build.0 = Debug|Any CPU + {38D80FC7-EBD4-4902-A114-C93AA75CFCA0}.Debug|x86.ActiveCfg = Debug|Any CPU + {38D80FC7-EBD4-4902-A114-C93AA75CFCA0}.Debug|x86.Build.0 = Debug|Any CPU + {38D80FC7-EBD4-4902-A114-C93AA75CFCA0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {38D80FC7-EBD4-4902-A114-C93AA75CFCA0}.Release|Any CPU.Build.0 = Release|Any CPU + {38D80FC7-EBD4-4902-A114-C93AA75CFCA0}.Release|ARM64.ActiveCfg = Release|Any CPU + {38D80FC7-EBD4-4902-A114-C93AA75CFCA0}.Release|ARM64.Build.0 = Release|Any CPU + {38D80FC7-EBD4-4902-A114-C93AA75CFCA0}.Release|x64.ActiveCfg = Release|Any CPU + {38D80FC7-EBD4-4902-A114-C93AA75CFCA0}.Release|x64.Build.0 = Release|Any CPU + {38D80FC7-EBD4-4902-A114-C93AA75CFCA0}.Release|x86.ActiveCfg = Release|Any CPU + {38D80FC7-EBD4-4902-A114-C93AA75CFCA0}.Release|x86.Build.0 = Release|Any CPU {FED9D707-E5C3-4867-87B0-FABDB5EB0823}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FED9D707-E5C3-4867-87B0-FABDB5EB0823}.Debug|Any CPU.Build.0 = Debug|Any CPU {FED9D707-E5C3-4867-87B0-FABDB5EB0823}.Debug|ARM64.ActiveCfg = Debug|Any CPU diff --git a/src/ext/Bal/WixToolset.Dnc.Host/BootstrapperApplicationFactory.cs b/src/ext/Bal/WixToolset.Dnc.Host/BootstrapperApplicationFactory.cs deleted file mode 100644 index d38fd1a9..00000000 --- a/src/ext/Bal/WixToolset.Dnc.Host/BootstrapperApplicationFactory.cs +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Dnc.Host -{ - using System; - using System.Linq; - using System.Reflection; - using System.Runtime.InteropServices; - - delegate IBootstrapperApplicationFactory StaticEntryDelegate([MarshalAs(UnmanagedType.LPWStr)] string baFactoryAssemblyName, [MarshalAs(UnmanagedType.LPWStr)] string baFactoryAssemblyPath); - - /// - /// Entry point for the .NET Core host to create and return the BA to the engine. - /// Reflection is used instead of referencing WixToolset.Mba.Core directly to avoid requiring it in the AssemblyLoadContext. - /// - public sealed class BootstrapperApplicationFactory : IBootstrapperApplicationFactory - { - private string baFactoryAssemblyName; - private string baFactoryAssemblyPath; - - public BootstrapperApplicationFactory(string baFactoryAssemblyName, string baFactoryAssemblyPath) - { - this.baFactoryAssemblyName = baFactoryAssemblyName; - this.baFactoryAssemblyPath = baFactoryAssemblyPath; - } - - /// - /// Loads the bootstrapper application assembly and calls its IBootstrapperApplicationFactory.Create method. - /// - /// Pointer to BOOTSTRAPPER_CREATE_ARGS struct. - /// Pointer to BOOTSTRAPPER_CREATE_RESULTS struct. - /// The bootstrapper application assembly - /// does not define the . - public void Create(IntPtr pArgs, IntPtr pResults) - { - // Load the BA's IBootstrapperApplicationFactory. - var baFactoryType = BootstrapperApplicationFactory.GetBAFactoryTypeFromAssembly(this.baFactoryAssemblyName, this.baFactoryAssemblyPath); - var baFactory = Activator.CreateInstance(baFactoryType); - if (null == baFactory) - { - throw new InvalidBootstrapperApplicationFactoryException(); - } - - var createMethod = baFactoryType.GetMethod(nameof(Create), new[] { typeof(IntPtr), typeof(IntPtr) }); - if (null == createMethod) - { - throw new InvalidBootstrapperApplicationFactoryException(); - } - createMethod.Invoke(baFactory, new object[] { pArgs, pResults }); - } - - /// - /// Locates the and returns the specified type. - /// - /// The assembly that defines the IBootstrapperApplicationFactory implementation. - /// The bootstrapper application factory . - private static Type GetBAFactoryTypeFromAssembly(string assemblyName, string assemblyPath) - { - // The default ALC shouldn't need help loading the assembly, since the host should have provided the deps.json - // when starting the runtime. But it doesn't hurt so keep this in case an isolated ALC is ever needed. - var alc = new DnchostAssemblyLoadContext(assemblyPath, false); - var asm = alc.LoadFromAssemblyName(new AssemblyName(assemblyName)); - - var attr = asm.GetCustomAttributes() - .Where(a => a.GetType().FullName == "WixToolset.Mba.Core.BootstrapperApplicationFactoryAttribute") - .SingleOrDefault(); - - if (null == attr) - { - throw new MissingAttributeException(); - } - - var baFactoryTypeProperty = attr.GetType().GetProperty("BootstrapperApplicationFactoryType", typeof(Type)); - if (baFactoryTypeProperty == null || baFactoryTypeProperty.GetMethod == null) - { - throw new MissingAttributeException(); - } - - var baFactoryType = (Type)baFactoryTypeProperty.GetMethod.Invoke(attr, null); - return baFactoryType; - } - - // Entry point for the DNC host. - public static IBootstrapperApplicationFactory CreateBAFactory([MarshalAs(UnmanagedType.LPWStr)] string baFactoryAssemblyName, [MarshalAs(UnmanagedType.LPWStr)] string baFactoryAssemblyPath) - { - return new BootstrapperApplicationFactory(baFactoryAssemblyName, baFactoryAssemblyPath); - } - } -} diff --git a/src/ext/Bal/WixToolset.Dnc.Host/DnchostAssemblyLoadContext.cs b/src/ext/Bal/WixToolset.Dnc.Host/DnchostAssemblyLoadContext.cs deleted file mode 100644 index 1a383058..00000000 --- a/src/ext/Bal/WixToolset.Dnc.Host/DnchostAssemblyLoadContext.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Dnc.Host -{ - using System; - using System.Reflection; - using System.Runtime.Loader; - - public sealed class DnchostAssemblyLoadContext : AssemblyLoadContext - { - private readonly AssemblyDependencyResolver resolver; - - public DnchostAssemblyLoadContext(string assemblyPath, bool isolateFromDefault) - : base(nameof(DnchostAssemblyLoadContext), isolateFromDefault) - { - this.resolver = new AssemblyDependencyResolver(assemblyPath); - - if (!this.IsCollectible) - { - AssemblyLoadContext.Default.Resolving += this.ResolveAssembly; - AssemblyLoadContext.Default.ResolvingUnmanagedDll += this.ResolveUnmanagedDll; - } - } - - private Assembly ResolveAssembly(AssemblyLoadContext defaultAlc, AssemblyName assemblyName) - { - var path = this.resolver.ResolveAssemblyToPath(assemblyName); - if (path != null) - { - var targetAlc = this.IsCollectible ? this : defaultAlc; - return targetAlc.LoadFromAssemblyPath(path); - } - - return null; - } - - private IntPtr ResolveUnmanagedDll(Assembly assembly, string unmanagedDllName) - { - var path = this.resolver.ResolveUnmanagedDllToPath(unmanagedDllName); - if (path != null) - { - return this.LoadUnmanagedDllFromPath(path); - } - - return IntPtr.Zero; - } - - protected override Assembly Load(AssemblyName assemblyName) - { - return this.ResolveAssembly(AssemblyLoadContext.Default, assemblyName); - } - - protected override IntPtr LoadUnmanagedDll(string unmanagedDllName) - { - return this.ResolveUnmanagedDll(null, unmanagedDllName); - } - } -} diff --git a/src/ext/Bal/WixToolset.Dnc.Host/Exceptions.cs b/src/ext/Bal/WixToolset.Dnc.Host/Exceptions.cs deleted file mode 100644 index 32d4d4c5..00000000 --- a/src/ext/Bal/WixToolset.Dnc.Host/Exceptions.cs +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Dnc.Host -{ - using System; - using System.Runtime.Serialization; - - /// - /// Base class for exception returned to the bootstrapper application host. - /// - [Serializable] - public abstract class BootstrapperException : Exception - { - /// - /// Creates an instance of the base class with the given HRESULT. - /// - /// The HRESULT for the exception that is used by the bootstrapper application host. - public BootstrapperException(int hr) - { - this.HResult = hr; - } - - /// - /// Initializes a new instance of the class. - /// - /// Exception message. - public BootstrapperException(string message) - : base(message) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// Exception message - /// Inner exception associated with this one - public BootstrapperException(string message, Exception innerException) - : base(message, innerException) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// Serialization information for this exception - /// Streaming context to serialize to - protected BootstrapperException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - } - - /// - /// The bootstrapper application assembly loaded by the host does not contain exactly one instance of the - /// class. - /// - /// - [Serializable] - public class MissingAttributeException : BootstrapperException - { - /// - /// Creates a new instance of the class. - /// - public MissingAttributeException() - : base(NativeMethods.E_NOTFOUND) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// Exception message. - public MissingAttributeException(string message) - : base(message) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// Exception message - /// Inner exception associated with this one - public MissingAttributeException(string message, Exception innerException) - : base(message, innerException) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// Serialization information for this exception - /// Streaming context to serialize to - protected MissingAttributeException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - } - - /// - /// The bootstrapper application factory specified by the - /// does not extend the base class. - /// - /// - /// - [Serializable] - public class InvalidBootstrapperApplicationFactoryException : BootstrapperException - { - /// - /// Creates a new instance of the class. - /// - public InvalidBootstrapperApplicationFactoryException() - : base(NativeMethods.E_UNEXPECTED) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// Exception message. - public InvalidBootstrapperApplicationFactoryException(string message) - : base(message) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// Exception message - /// Inner exception associated with this one - public InvalidBootstrapperApplicationFactoryException(string message, Exception innerException) - : base(message, innerException) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// Serialization information for this exception - /// Streaming context to serialize to - protected InvalidBootstrapperApplicationFactoryException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - } -} diff --git a/src/ext/Bal/WixToolset.Dnc.Host/IBootstrapperApplicationFactory.cs b/src/ext/Bal/WixToolset.Dnc.Host/IBootstrapperApplicationFactory.cs deleted file mode 100644 index 96731192..00000000 --- a/src/ext/Bal/WixToolset.Dnc.Host/IBootstrapperApplicationFactory.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Dnc.Host -{ - using System; - using System.Runtime.InteropServices; - - [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - public interface IBootstrapperApplicationFactory - { - void Create( - IntPtr pArgs, - IntPtr pResults - ); - } -} diff --git a/src/ext/Bal/WixToolset.Dnc.Host/NativeMethods.cs b/src/ext/Bal/WixToolset.Dnc.Host/NativeMethods.cs deleted file mode 100644 index 6dc393c6..00000000 --- a/src/ext/Bal/WixToolset.Dnc.Host/NativeMethods.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Dnc.Host -{ - using System; - using System.Runtime.InteropServices; - - /// - /// Contains native constants, functions, and structures for this assembly. - /// - internal static class NativeMethods - { - #region Error Constants - internal const int E_NOTFOUND = unchecked((int)0x80070490); - internal const int E_UNEXPECTED = unchecked((int)0x8000ffff); - #endregion - } -} diff --git a/src/ext/Bal/WixToolset.Dnc.Host/WixToolset.Dnc.Host.csproj b/src/ext/Bal/WixToolset.Dnc.Host/WixToolset.Dnc.Host.csproj deleted file mode 100644 index a2f0d8ec..00000000 --- a/src/ext/Bal/WixToolset.Dnc.Host/WixToolset.Dnc.Host.csproj +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - netcoreapp3.1 - WixToolset.Dnc.Host - WiX Toolset .NET Core BA Host - WiX Toolset .NET Core BA Host - embedded - AnyCPU - - - - - False - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/ext/Bal/WixToolset.Dnc.HostGenerator/DncHostGenerator.cs b/src/ext/Bal/WixToolset.Dnc.HostGenerator/DncHostGenerator.cs new file mode 100644 index 00000000..088b2b49 --- /dev/null +++ b/src/ext/Bal/WixToolset.Dnc.HostGenerator/DncHostGenerator.cs @@ -0,0 +1,127 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dnc.HostGenerator +{ + using System; + using System.Diagnostics.CodeAnalysis; + using System.Text; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.Text; + + [Generator] + public sealed class DncHostGenerator : ISourceGenerator + { + 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}"); + public static readonly string TargetAttributeFullName = "WixToolset.Mba.Core.BootstrapperApplicationFactoryAttribute"; + + [SuppressMessage("MicrosoftCodeAnalysisReleaseTracking", "RS2008:Enable analyzer release tracking", Justification = "Tracking not needed")] + public static readonly DiagnosticDescriptor MissingFactoryAttributeDescriptor = new DiagnosticDescriptor( + "WIXBAL001", + $"Missing assembly level attribute {TargetAttributeFullName}.", + $"Add [assembly: {TargetAttributeFullName}(typeof()].", + "WixToolset.Bal.wixext", + DiagnosticSeverity.Error, + true + ); + + public void Initialize(GeneratorInitializationContext context) + { + } + + public void Execute(GeneratorExecutionContext context) + { + var symbolDisplayFormat = new SymbolDisplayFormat(typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces); + + string baFactoryClassName = null; + foreach (var assemblyAttribute in context.Compilation.Assembly.GetAttributes()) + { + var fullAssemblyTypeName = assemblyAttribute.AttributeClass.ToDisplayString(symbolDisplayFormat); + + if (fullAssemblyTypeName == TargetAttributeFullName && + assemblyAttribute.ConstructorArguments.Length == 1) + { + var arg = assemblyAttribute.ConstructorArguments[0]; + if (arg.Value is INamedTypeSymbol argValue) + { + baFactoryClassName = argValue.ToDisplayString(symbolDisplayFormat); + break; + } + } + } + + if (baFactoryClassName == null) + { + context.ReportDiagnostic(Diagnostic.Create(MissingFactoryAttributeDescriptor, null)); + } + else + { + var source = String.Format(Template, Version, baFactoryClassName); + context.AddSource("WixToolset.Dnc.Host.g.cs", SourceText.From(source, Encoding.UTF8, SourceHashAlgorithm.Sha256)); + } + } + + public const string Template = @" +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WixToolset.Dnc.Host +{{ + using System; + using System.CodeDom.Compiler; + using System.Diagnostics.CodeAnalysis; + using System.Linq; + using System.Reflection; + using System.Runtime.CompilerServices; + using System.Runtime.InteropServices; + using WixToolset.Mba.Core; + + [GeneratedCode(""WixToolset.Dnc.HostGenerator.DncHostGenerator"", ""{0}"")] + [CompilerGenerated] + delegate IBootstrapperApplicationFactory StaticEntryDelegate(); + + /// + /// Entry point for the .NET Core host to create and return the BA to the engine. + /// + [GeneratedCode(""WixToolset.Dnc.HostGenerator.DncHostGenerator"", ""{0}"")] + [CompilerGenerated] + public sealed class BootstrapperApplicationFactory : IBootstrapperApplicationFactory + {{ + /// + /// Creates the bootstrapper application factory and calls its IBootstrapperApplicationFactory.Create method. + /// + /// Pointer to BOOTSTRAPPER_CREATE_ARGS struct. + /// Pointer to BOOTSTRAPPER_CREATE_RESULTS struct. + public void Create(IntPtr pArgs, IntPtr pResults) + {{ + var baFactory = new {1}(); + baFactory.Create(pArgs, pResults); + }} + + // Entry point for the DNC host. + public static IBootstrapperApplicationFactory CreateBAFactory() + {{ + return new BootstrapperApplicationFactory(); + }} + +#if NET5_0_OR_GREATER + [ModuleInitializer] + [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(BootstrapperApplicationFactory))] +#if NET5_0 + [DynamicDependency(""GetFunctionPointer(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr)"", ""Internal.Runtime.InteropServices.ComponentActivator"", ""System.Private.CoreLib"")] +#endif + /// + /// Empty method to attach above attributes to support linker trimming. + /// + public static void ModuleInitialize() {{ }} +#endif + }} +}} +"; + } +} diff --git a/src/ext/Bal/WixToolset.Dnc.HostGenerator/WixToolset.Dnc.HostGenerator.csproj b/src/ext/Bal/WixToolset.Dnc.HostGenerator/WixToolset.Dnc.HostGenerator.csproj new file mode 100644 index 00000000..2c33ac3c --- /dev/null +++ b/src/ext/Bal/WixToolset.Dnc.HostGenerator/WixToolset.Dnc.HostGenerator.csproj @@ -0,0 +1,27 @@ + + + + + + netstandard2.0 + WixToolset.Dnc.HostGenerator + WiX Toolset .NET Core BA Host Generator + WiX Toolset .NET Core BA Host Generator + embedded + AnyCPU + true + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/src/ext/Bal/WixToolset.Dnc.HostGenerator/WixToolset.Dnc.HostGenerator.nuspec b/src/ext/Bal/WixToolset.Dnc.HostGenerator/WixToolset.Dnc.HostGenerator.nuspec new file mode 100644 index 00000000..46dd7248 --- /dev/null +++ b/src/ext/Bal/WixToolset.Dnc.HostGenerator/WixToolset.Dnc.HostGenerator.nuspec @@ -0,0 +1,23 @@ + + + + $id$ + $version$ + $title$ + $description$ + $authors$ + MS-RL + false + $copyright$ + $projectUrl$ + + + + + + + + + + + diff --git a/src/ext/Bal/WixToolset.Dnc.HostGenerator/build/WixToolset.Dnc.HostGenerator.props b/src/ext/Bal/WixToolset.Dnc.HostGenerator/build/WixToolset.Dnc.HostGenerator.props new file mode 100644 index 00000000..f9306af7 --- /dev/null +++ b/src/ext/Bal/WixToolset.Dnc.HostGenerator/build/WixToolset.Dnc.HostGenerator.props @@ -0,0 +1,10 @@ + + + + + + true + true + <_EnableConsumingManagedCodeFromNativeHosting>true + + diff --git a/src/ext/Bal/WixToolset.Dnc.HostGenerator/build/WixToolset.Dnc.HostGenerator.targets b/src/ext/Bal/WixToolset.Dnc.HostGenerator/build/WixToolset.Dnc.HostGenerator.targets new file mode 100644 index 00000000..d536ef5f --- /dev/null +++ b/src/ext/Bal/WixToolset.Dnc.HostGenerator/build/WixToolset.Dnc.HostGenerator.targets @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/ext/Bal/bal.cmd b/src/ext/Bal/bal.cmd index f8894f76..75f3502b 100644 --- a/src/ext/Bal/bal.cmd +++ b/src/ext/Bal/bal.cmd @@ -2,11 +2,12 @@ @pushd %~dp0 @set _C=Debug +@set _L=%~dp0..\..\..\build\logs :parse_args @if /i "%1"=="release" set _C=Release @if not "%1"=="" shift & goto parse_args -@echo Building ext\Util %_C% using %_N% +@echo Building ext\Bal %_C% using %_N% :: Restore nuget restore dnchost\packages.config || exit /b @@ -22,6 +23,9 @@ msbuild -p:Configuration=%_C%;Platform=x64 mbahost\mbahost.vcxproj || exit /b msbuild -p:Configuration=%_C%;Platform=ARM64 mbahost\mbahost.vcxproj || exit /b msbuild -p:Configuration=%_C% || exit /b + +dotnet test test\WixToolsetTest.Dnc.HostGenerator -c %_C% --nologo --no-build -l "trx;LogFileName=%_L%\TestResults\WixToolsetTest.Dnc.HostGenerator.trx" || exit /b + msbuild -p:Configuration=%_C% test\examples\examples.proj || exit /b :: Test @@ -31,6 +35,7 @@ dotnet test -c %_C% --no-build test\WixToolsetTest.Bal || exit /b :: Pack msbuild -t:Pack -p:Configuration=%_C% -p:NoBuild=true wixext\WixToolset.Bal.wixext.csproj || exit /b +msbuild -t:Pack -p:Configuration=%_C% -p:NoBuild=true WixToolset.Dnc.HostGenerator\WixToolset.Dnc.HostGenerator.csproj || exit /b msbuild -t:Pack -p:Configuration=%_C% -p:NoBuild=true WixToolset.Mba.Host\WixToolset.Mba.Host.csproj || exit /b @popd diff --git a/src/ext/Bal/dnchost/dnchost.cpp b/src/ext/Bal/dnchost/dnchost.cpp index 8ca326fc..dcc9fa56 100644 --- a/src/ext/Bal/dnchost/dnchost.cpp +++ b/src/ext/Bal/dnchost/dnchost.cpp @@ -154,9 +154,6 @@ static HRESULT LoadModulePaths( hr = PathGetDirectory(pState->sczModuleFullPath, &pState->sczAppBase); BalExitOnFailure(hr, "Failed to get the directory of the full process path."); - hr = PathConcat(pState->sczAppBase, DNC_ASSEMBLY_FILE_NAME, &pState->sczManagedHostPath); - BalExitOnFailure(hr, "Failed to create managed host path."); - LExit: return hr; } @@ -249,7 +246,7 @@ static HRESULT LoadRuntime( hr = DnchostLoadRuntime( &pState->hostfxrState, pState->sczModuleFullPath, - pState->sczManagedHostPath, + pState->sczBaFactoryAssemblyPath, pState->sczBaFactoryDepsJsonPath, pState->sczBaFactoryRuntimeConfigPath); diff --git a/src/ext/Bal/dnchost/dnchost.h b/src/ext/Bal/dnchost/dnchost.h index 22fd8f5e..b0ba9638 100644 --- a/src/ext/Bal/dnchost/dnchost.h +++ b/src/ext/Bal/dnchost/dnchost.h @@ -23,7 +23,6 @@ struct DNCSTATE HINSTANCE hInstance; LPWSTR sczModuleFullPath; LPWSTR sczAppBase; - LPWSTR sczManagedHostPath; LPWSTR sczBaFactoryAssemblyName; LPWSTR sczBaFactoryAssemblyPath; LPWSTR sczBaFactoryDepsJsonPath; diff --git a/src/ext/Bal/dnchost/dnchost.vcxproj b/src/ext/Bal/dnchost/dnchost.vcxproj index 66e52c6f..1fd2ebed 100644 --- a/src/ext/Bal/dnchost/dnchost.vcxproj +++ b/src/ext/Bal/dnchost/dnchost.vcxproj @@ -80,14 +80,6 @@ - - - {0D780900-C2FF-4FA2-8CB5-8A19768724C5} - false - true - - - diff --git a/src/ext/Bal/dnchost/dncutil.cpp b/src/ext/Bal/dnchost/dncutil.cpp index 34d14911..6486e6e9 100644 --- a/src/ext/Bal/dnchost/dncutil.cpp +++ b/src/ext/Bal/dnchost/dncutil.cpp @@ -2,6 +2,12 @@ #include "precomp.h" +#define DNC_ENTRY_TYPE "WixToolset.Dnc.Host.BootstrapperApplicationFactory" +#define DNC_ENTRY_TYPEW L"WixToolset.Dnc.Host.BootstrapperApplicationFactory" +#define DNC_STATIC_ENTRY_METHOD "CreateBAFactory" +#define DNC_STATIC_ENTRY_METHODW L"CreateBAFactory" +#define DNC_STATIC_ENTRY_DELEGATEW L"WixToolset.Dnc.Host.StaticEntryDelegate" + // https://github.com/dotnet/runtime/blob/master/src/installer/corehost/error_codes.h #define InvalidArgFailure 0x80008081 #define HostApiBufferTooSmall 0x80008098 @@ -74,19 +80,28 @@ LExit: HRESULT DnchostCreateFactory( __in HOSTFXR_STATE* pState, __in LPCWSTR wzBaFactoryAssemblyName, - __in LPCWSTR wzBaFactoryAssemblyPath, + __in LPCWSTR /*wzBaFactoryAssemblyPath*/, __out IBootstrapperApplicationFactory** ppAppFactory ) { HRESULT hr = S_OK; PFNCREATEBAFACTORY pfnCreateBAFactory = NULL; + LPWSTR sczEntryType = NULL; + LPWSTR sczEntryDelegate = NULL; + LPSTR sczBaFactoryAssemblyName = NULL; if (pState->pfnGetFunctionPointer) { + hr = StrAllocFormatted(&sczEntryType, L"%ls,%ls", DNC_ENTRY_TYPEW, wzBaFactoryAssemblyName); + BalExitOnFailure(hr, "Failed to format entry type."); + + hr = StrAllocFormatted(&sczEntryDelegate, L"%ls,%ls", DNC_STATIC_ENTRY_DELEGATEW, wzBaFactoryAssemblyName); + BalExitOnFailure(hr, "Failed to format entry delegate."); + hr = pState->pfnGetFunctionPointer( - DNC_ENTRY_TYPEW, + sczEntryType, DNC_STATIC_ENTRY_METHODW, - DNC_STATIC_ENTRY_DELEGATEW, + sczEntryDelegate, NULL, NULL, reinterpret_cast(&pfnCreateBAFactory)); @@ -94,19 +109,26 @@ HRESULT DnchostCreateFactory( } else { + hr = StrAnsiAllocString(&sczBaFactoryAssemblyName, wzBaFactoryAssemblyName, 0, CP_UTF8); + BalExitOnFailure(hr, "Failed to convert assembly name to UTF8: %ls", wzBaFactoryAssemblyName); + hr = pState->pfnCoreclrCreateDelegate( pState->pClrHandle, pState->dwDomainId, - DNC_ASSEMBLY_FULL_NAME, + sczBaFactoryAssemblyName, DNC_ENTRY_TYPE, DNC_STATIC_ENTRY_METHOD, reinterpret_cast(&pfnCreateBAFactory)); BalExitOnFailure(hr, "Failed to create delegate in app domain."); } - *ppAppFactory = pfnCreateBAFactory(wzBaFactoryAssemblyName, wzBaFactoryAssemblyPath); + *ppAppFactory = pfnCreateBAFactory(); LExit: + ReleaseStr(sczEntryType); + ReleaseStr(sczEntryDelegate); + ReleaseStr(sczBaFactoryAssemblyName); + return hr; } @@ -233,7 +255,7 @@ static HRESULT InitializeCoreClr( } else { - ExitOnFailure(hr, "HostfxrGetRuntimeDelegate failed"); + BalExitOnFailure(hr, "HostfxrGetRuntimeDelegate failed"); } LExit: @@ -295,6 +317,8 @@ static HRESULT InitializeCoreClrPre5( for (DWORD i = 0; i < cDirectories; ++i) { + Assert(rgDirectories); + hr = PathConcat(rgDirectories[i], L"coreclr.dll", &sczCoreClrPath); BalExitOnFailure(hr, "Failed to allocate path to coreclr."); @@ -324,9 +348,9 @@ static HRESULT InitializeCoreClrPre5( BalExitOnFailure(hr, "Failed to start coreclr."); LExit: - MemFree(rgDirectories); - MemFree(rgPropertyValues); - MemFree(rgPropertyKeys); + ReleaseMem(rgDirectories); + ReleaseMem(rgPropertyValues); + ReleaseMem(rgPropertyKeys); ReleaseStr(sczCoreClrPath); return hr; diff --git a/src/ext/Bal/dnchost/dncutil.h b/src/ext/Bal/dnchost/dncutil.h index 85eda3b2..f88e3f77 100644 --- a/src/ext/Bal/dnchost/dncutil.h +++ b/src/ext/Bal/dnchost/dncutil.h @@ -1,10 +1,7 @@ #pragma once // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -typedef IBootstrapperApplicationFactory* (STDMETHODCALLTYPE* PFNCREATEBAFACTORY)( - __in LPCWSTR wzBaFactoryAssemblyName, - __in LPCWSTR wzBaFactoryAssemblyPath - ); +typedef IBootstrapperApplicationFactory* (STDMETHODCALLTYPE* PFNCREATEBAFACTORY)(); struct HOSTFXR_STATE { diff --git a/src/ext/Bal/dnchost/precomp.h b/src/ext/Bal/dnchost/precomp.h index 84ff6424..7aefc4e3 100644 --- a/src/ext/Bal/dnchost/precomp.h +++ b/src/ext/Bal/dnchost/precomp.h @@ -20,7 +20,6 @@ #include #include -#include #define NETHOST_USE_AS_STATIC #include #include diff --git a/src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/CSharpSourceGeneratorVerifier.cs b/src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/CSharpSourceGeneratorVerifier.cs new file mode 100644 index 00000000..27729ac8 --- /dev/null +++ b/src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/CSharpSourceGeneratorVerifier.cs @@ -0,0 +1,45 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolsetTest.Dnc.HostGenerator +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Testing; + using Microsoft.CodeAnalysis.Testing.Verifiers; + + public static class CSharpSourceGeneratorVerifier + where TSourceGenerator : ISourceGenerator, new() + { + public class Test : CSharpSourceGeneratorTest + { + public Test() + { + } + + protected override CompilationOptions CreateCompilationOptions() + { + var compilationOptions = base.CreateCompilationOptions(); + return compilationOptions.WithSpecificDiagnosticOptions( + compilationOptions.SpecificDiagnosticOptions.SetItems(GetNullableWarningsFromCompiler())); + } + + public LanguageVersion LanguageVersion { get; set; } = LanguageVersion.Default; + + private static ImmutableDictionary GetNullableWarningsFromCompiler() + { + string[] args = { "/warnaserror:nullable" }; + var commandLineArguments = CSharpCommandLineParser.Default.Parse(args, baseDirectory: Environment.CurrentDirectory, sdkDirectory: Environment.CurrentDirectory); + var nullableWarnings = commandLineArguments.CompilationOptions.SpecificDiagnosticOptions; + + return nullableWarnings; + } + + protected override ParseOptions CreateParseOptions() + { + return ((CSharpParseOptions)base.CreateParseOptions()).WithLanguageVersion(this.LanguageVersion); + } + } + } +} diff --git a/src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/DncHostGeneratorTests.cs b/src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/DncHostGeneratorTests.cs new file mode 100644 index 00000000..6ede1089 --- /dev/null +++ b/src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/DncHostGeneratorTests.cs @@ -0,0 +1,88 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolsetTest.Dnc.HostGenerator +{ + using System; + using System.Text; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.Testing; + using Microsoft.CodeAnalysis.Text; + using WixToolset.Dnc.HostGenerator; + using WixToolset.Mba.Core; + using Xunit; + + using VerifyCS = CSharpSourceGeneratorVerifier; + + public class DncHostGeneratorTests + { + static readonly MetadataReference MbaCoreAssembly = MetadataReference.CreateFromFile(typeof(BootstrapperApplicationFactoryAttribute).Assembly.Location); + + [Fact] + public async Task FailsBuildWhenMissingAttribute() + { + var code = @" +//[assembly: WixToolset.Mba.Core.BootstrapperApplicationFactory(typeof(Test.BAFactory))] +namespace Test +{ + using WixToolset.Mba.Core; + + public class BAFactory : BaseBootstrapperApplicationFactory + { + protected override IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand) + { + return null; + } + } +} +"; + + await new VerifyCS.Test + { + TestState = + { + Sources = { code }, + AdditionalReferences = { MbaCoreAssembly }, + ExpectedDiagnostics = + { + new DiagnosticResult(DncHostGenerator.MissingFactoryAttributeDescriptor), + }, + }, + }.RunAsync(); + } + + [Fact] + public async Task GeneratesEntryPoint() + { + var code = @" +[assembly: WixToolset.Mba.Core.BootstrapperApplicationFactory(typeof(Test.BAFactory))] +namespace Test +{ + using WixToolset.Mba.Core; + + public class BAFactory : BaseBootstrapperApplicationFactory + { + protected override IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand) + { + return null; + } + } +} +"; + var generated = String.Format(DncHostGenerator.Template, DncHostGenerator.Version, "Test.BAFactory"); + + await new VerifyCS.Test + { + TestState = + { + Sources = { code }, + GeneratedSources = + { + (typeof(DncHostGenerator), "WixToolset.Dnc.Host.g.cs", SourceText.From(generated, Encoding.UTF8, SourceHashAlgorithm.Sha256)), + }, + AdditionalReferences = { MbaCoreAssembly }, + }, + }.RunAsync(); + } + } +} diff --git a/src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/WixToolsetTest.Dnc.HostGenerator.csproj b/src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/WixToolsetTest.Dnc.HostGenerator.csproj new file mode 100644 index 00000000..0c2b33fd --- /dev/null +++ b/src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/WixToolsetTest.Dnc.HostGenerator.csproj @@ -0,0 +1,27 @@ + + + + + + netcoreapp3.1 + false + false + + + + + + + + + + + + + + + + + + + diff --git a/src/ext/Bal/test/WixToolsetTest.ManagedHost/DncHostFixture.cs b/src/ext/Bal/test/WixToolsetTest.ManagedHost/DncHostFixture.cs index 8dd5ff11..14b80fe8 100644 --- a/src/ext/Bal/test/WixToolsetTest.ManagedHost/DncHostFixture.cs +++ b/src/ext/Bal/test/WixToolsetTest.ManagedHost/DncHostFixture.cs @@ -2,9 +2,7 @@ namespace WixToolsetTest.ManagedHost { - using System.IO; using WixBuildTools.TestSupport; - using WixToolset.Core.TestPackage; using Xunit; public class DncHostFixture @@ -21,11 +19,13 @@ namespace WixToolsetTest.ManagedHost var testEngine = new TestEngine(); var result = testEngine.RunShutdownEngine(bundleFile, baseFolder); - var logMessages = result.Output; - Assert.Equal("Loading .NET Core FDD bootstrapper application.", logMessages[0]); - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]); - Assert.Equal("EarliestCoreBA", logMessages[2]); - Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]); + WixAssert.CompareLineByLine(new[] + { + "Loading .NET Core FDD bootstrapper application.", + "Creating BA thread to run asynchronously.", + "EarliestCoreBA", + "Shutdown,ReloadBootstrapper,0", + }, result.Output.ToArray()); } } @@ -39,14 +39,17 @@ namespace WixToolsetTest.ManagedHost var testEngine = new TestEngine(); var result = testEngine.RunShutdownEngine(bundleFile, baseFolder); - var logMessages = result.Output; - Assert.Equal("Loading .NET Core SCD bootstrapper application.", logMessages[0]); - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]); - Assert.Equal("EarliestCoreBA", logMessages[2]); - Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]); + WixAssert.CompareLineByLine(new[] + { + "Loading .NET Core SCD bootstrapper application.", + "Creating BA thread to run asynchronously.", + "EarliestCoreBA", + "Shutdown,ReloadBootstrapper,0", + }, result.Output.ToArray()); } } + [Fact] public void CanLoadTrimmedSCDEarliestCoreMBA() { using (var fs = new DisposableFileSystem()) @@ -56,11 +59,13 @@ namespace WixToolsetTest.ManagedHost var testEngine = new TestEngine(); var result = testEngine.RunShutdownEngine(bundleFile, baseFolder); - var logMessages = result.Output; - Assert.Equal("Loading .NET Core SCD bootstrapper application.", logMessages[0]); - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]); - Assert.Equal("EarliestCoreBA", logMessages[2]); - Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]); + WixAssert.CompareLineByLine(new[] + { + "Loading .NET Core SCD bootstrapper application.", + "Creating BA thread to run asynchronously.", + "EarliestCoreBA", + "Shutdown,ReloadBootstrapper,0", + }, result.Output.ToArray()); } } @@ -74,16 +79,19 @@ namespace WixToolsetTest.ManagedHost var testEngine = new TestEngine(); var result = testEngine.RunReloadEngine(bundleFile, baseFolder); - var logMessages = result.Output; - Assert.Equal("Loading .NET Core SCD bootstrapper application.", logMessages[0]); - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]); - Assert.Equal("EarliestCoreBA", logMessages[2]); - Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]); - Assert.Equal("Loading .NET Core SCD bootstrapper application.", logMessages[4]); - Assert.Equal("Reloaded 1 time(s)", logMessages[5]); // dnchost doesn't currently support unloading - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[6]); - Assert.Equal("EarliestCoreBA", logMessages[7]); - Assert.Equal("Shutdown,Restart,0", logMessages[8]); + WixAssert.CompareLineByLine(new[] + { + "Loading .NET Core SCD bootstrapper application.", + "Creating BA thread to run asynchronously.", + "EarliestCoreBA", + "Shutdown,ReloadBootstrapper,0", + "Loading .NET Core SCD bootstrapper application.", + "Reloaded 1 time(s)", // dnchost doesn't currently support unloading + "Creating BA thread to run asynchronously.", + "EarliestCoreBA", + "Shutdown,Restart,0", + + }, result.Output.ToArray()); } } @@ -97,11 +105,13 @@ namespace WixToolsetTest.ManagedHost var testEngine = new TestEngine(); var result = testEngine.RunShutdownEngine(bundleFile, baseFolder); - var logMessages = result.Output; - Assert.Equal("Loading .NET Core FDD bootstrapper application.", logMessages[0]); - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]); - Assert.Equal("LatestCoreBA", logMessages[2]); - Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]); + WixAssert.CompareLineByLine(new[] + { + "Loading .NET Core FDD bootstrapper application.", + "Creating BA thread to run asynchronously.", + "LatestCoreBA", + "Shutdown,ReloadBootstrapper,0", + }, result.Output.ToArray()); } } @@ -115,16 +125,18 @@ namespace WixToolsetTest.ManagedHost var testEngine = new TestEngine(); var result = testEngine.RunReloadEngine(bundleFile, baseFolder); - var logMessages = result.Output; - Assert.Equal("Loading .NET Core FDD bootstrapper application.", logMessages[0]); - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]); - Assert.Equal("LatestCoreBA", logMessages[2]); - Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]); - Assert.Equal("Loading .NET Core FDD bootstrapper application.", logMessages[4]); - Assert.Equal("Reloaded 1 time(s)", logMessages[5]); // dnchost doesn't currently support unloading - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[6]); - Assert.Equal("LatestCoreBA", logMessages[7]); - Assert.Equal("Shutdown,Restart,0", logMessages[8]); + WixAssert.CompareLineByLine(new[] + { + "Loading .NET Core FDD bootstrapper application.", + "Creating BA thread to run asynchronously.", + "LatestCoreBA", + "Shutdown,ReloadBootstrapper,0", + "Loading .NET Core FDD bootstrapper application.", + "Reloaded 1 time(s)", // dnchost doesn't currently support unloading + "Creating BA thread to run asynchronously.", + "LatestCoreBA", + "Shutdown,Restart,0", + }, result.Output.ToArray()); } } @@ -138,11 +150,14 @@ namespace WixToolsetTest.ManagedHost var testEngine = new TestEngine(); var result = testEngine.RunShutdownEngine(bundleFile, baseFolder); + WixAssert.CompareLineByLine(new[] + { + "Loading .NET Core SCD bootstrapper application.", + "Creating BA thread to run asynchronously.", + "LatestCoreBA", + "Shutdown,ReloadBootstrapper,0", + }, result.Output.ToArray()); var logMessages = result.Output; - Assert.Equal("Loading .NET Core SCD bootstrapper application.", logMessages[0]); - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]); - Assert.Equal("LatestCoreBA", logMessages[2]); - Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]); } } @@ -156,11 +171,13 @@ namespace WixToolsetTest.ManagedHost var testEngine = new TestEngine(); var result = testEngine.RunShutdownEngine(bundleFile, baseFolder); - var logMessages = result.Output; - Assert.Equal("Loading .NET Core SCD bootstrapper application.", logMessages[0]); - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]); - Assert.Equal("LatestCoreBA", logMessages[2]); - Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]); + WixAssert.CompareLineByLine(new[] + { + "Loading .NET Core SCD bootstrapper application.", + "Creating BA thread to run asynchronously.", + "LatestCoreBA", + "Shutdown,ReloadBootstrapper,0", + }, result.Output.ToArray()); } } @@ -174,16 +191,18 @@ namespace WixToolsetTest.ManagedHost var testEngine = new TestEngine(); var result = testEngine.RunReloadEngine(bundleFile, baseFolder); - var logMessages = result.Output; - Assert.Equal("Loading .NET Core SCD bootstrapper application.", logMessages[0]); - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]); - Assert.Equal("LatestCoreBA", logMessages[2]); - Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]); - Assert.Equal("Loading .NET Core SCD bootstrapper application.", logMessages[4]); - Assert.Equal("Reloaded 1 time(s)", logMessages[5]); // dnchost doesn't currently support unloading - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[6]); - Assert.Equal("LatestCoreBA", logMessages[7]); - Assert.Equal("Shutdown,Restart,0", logMessages[8]); + WixAssert.CompareLineByLine(new[] + { + "Loading .NET Core SCD bootstrapper application.", + "Creating BA thread to run asynchronously.", + "LatestCoreBA", + "Shutdown,ReloadBootstrapper,0", + "Loading .NET Core SCD bootstrapper application.", + "Reloaded 1 time(s)", // dnchost doesn't currently support unloading + "Creating BA thread to run asynchronously.", + "LatestCoreBA", + "Shutdown,Restart,0", + }, result.Output.ToArray()); } } @@ -197,11 +216,13 @@ namespace WixToolsetTest.ManagedHost var testEngine = new TestEngine(); var result = testEngine.RunShutdownEngine(bundleFile, baseFolder); - var logMessages = result.Output; - Assert.Equal("Loading .NET Core FDD bootstrapper application.", logMessages[0]); - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]); - Assert.Equal("WPFCoreBA", logMessages[2]); - Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]); + WixAssert.CompareLineByLine(new[] + { + "Loading .NET Core FDD bootstrapper application.", + "Creating BA thread to run asynchronously.", + "WPFCoreBA", + "Shutdown,ReloadBootstrapper,0", + }, result.Output.ToArray()); } } } diff --git a/src/ext/Bal/test/WixToolsetTest.ManagedHost/MbaHostFixture.cs b/src/ext/Bal/test/WixToolsetTest.ManagedHost/MbaHostFixture.cs index dd37ee58..b4ebe1c6 100644 --- a/src/ext/Bal/test/WixToolsetTest.ManagedHost/MbaHostFixture.cs +++ b/src/ext/Bal/test/WixToolsetTest.ManagedHost/MbaHostFixture.cs @@ -2,9 +2,7 @@ namespace WixToolsetTest.ManagedHost { - using System.IO; using WixBuildTools.TestSupport; - using WixToolset.Core.TestPackage; using Xunit; public class MbaHostFixture @@ -21,11 +19,13 @@ namespace WixToolsetTest.ManagedHost var testEngine = new TestEngine(); var result = testEngine.RunShutdownEngine(bundleFile, baseFolder); - var logMessages = result.Output; - Assert.Equal("Loading managed bootstrapper application.", logMessages[0]); - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]); - Assert.Equal("FullFramework2BA", logMessages[2]); - Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]); + WixAssert.CompareLineByLine(new[] + { + "Loading managed bootstrapper application.", + "Creating BA thread to run asynchronously.", + "FullFramework2BA", + "Shutdown,ReloadBootstrapper,0", + }, result.Output.ToArray()); } } @@ -39,11 +39,13 @@ namespace WixToolsetTest.ManagedHost var testEngine = new TestEngine(); var result = testEngine.RunShutdownEngine(bundleFile, baseFolder); - var logMessages = result.Output; - Assert.Equal("Loading managed bootstrapper application.", logMessages[0]); - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]); - Assert.Equal("FullFramework4BA", logMessages[2]); - Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]); + WixAssert.CompareLineByLine(new[] + { + "Loading managed bootstrapper application.", + "Creating BA thread to run asynchronously.", + "FullFramework4BA", + "Shutdown,ReloadBootstrapper,0", + }, result.Output.ToArray()); } } @@ -57,15 +59,17 @@ namespace WixToolsetTest.ManagedHost var testEngine = new TestEngine(); var result = testEngine.RunReloadEngine(bundleFile, baseFolder); - var logMessages = result.Output; - Assert.Equal("Loading managed bootstrapper application.", logMessages[0]); - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]); - Assert.Equal("FullFramework2BA", logMessages[2]); - Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]); - Assert.Equal("Loading managed bootstrapper application.", logMessages[4]); - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[5]); - Assert.Equal("FullFramework2BA", logMessages[6]); - Assert.Equal("Shutdown,Restart,0", logMessages[7]); + WixAssert.CompareLineByLine(new[] + { + "Loading managed bootstrapper application.", + "Creating BA thread to run asynchronously.", + "FullFramework2BA", + "Shutdown,ReloadBootstrapper,0", + "Loading managed bootstrapper application.", + "Creating BA thread to run asynchronously.", + "FullFramework2BA", + "Shutdown,Restart,0", + }, result.Output.ToArray()); } } @@ -79,15 +83,17 @@ namespace WixToolsetTest.ManagedHost var testEngine = new TestEngine(); var result = testEngine.RunReloadEngine(bundleFile, baseFolder); - var logMessages = result.Output; - Assert.Equal("Loading managed bootstrapper application.", logMessages[0]); - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]); - Assert.Equal("FullFramework4BA", logMessages[2]); - Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]); - Assert.Equal("Loading managed bootstrapper application.", logMessages[4]); - Assert.Equal("Creating BA thread to run asynchronously.", logMessages[5]); - Assert.Equal("FullFramework4BA", logMessages[6]); - Assert.Equal("Shutdown,Restart,0", logMessages[7]); + WixAssert.CompareLineByLine(new[] + { + "Loading managed bootstrapper application.", + "Creating BA thread to run asynchronously.", + "FullFramework4BA", + "Shutdown,ReloadBootstrapper,0", + "Loading managed bootstrapper application.", + "Creating BA thread to run asynchronously.", + "FullFramework4BA", + "Shutdown,Restart,0", + }, result.Output.ToArray()); } } } diff --git a/src/ext/Bal/test/WixToolsetTest.ManagedHost/TestEngine.cs b/src/ext/Bal/test/WixToolsetTest.ManagedHost/TestEngine.cs index 9d7fc9db..30d97f3e 100644 --- a/src/ext/Bal/test/WixToolsetTest.ManagedHost/TestEngine.cs +++ b/src/ext/Bal/test/WixToolsetTest.ManagedHost/TestEngine.cs @@ -2,6 +2,7 @@ namespace WixToolsetTest.ManagedHost { + using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; @@ -41,7 +42,7 @@ namespace WixToolsetTest.ManagedHost { var startInfo = new ProcessStartInfo(executablePath) { - Arguments = string.Join(' ', arguments), + Arguments = String.Join(' ', arguments), CreateNoWindow = true, RedirectStandardError = true, RedirectStandardOutput = true, diff --git a/src/ext/Bal/test/examples/Directory.Build.props b/src/ext/Bal/test/examples/Directory.Build.props index 52b931f6..7f38564a 100644 --- a/src/ext/Bal/test/examples/Directory.Build.props +++ b/src/ext/Bal/test/examples/Directory.Build.props @@ -2,5 +2,6 @@ - + + diff --git a/src/ext/Bal/test/examples/Directory.Build.targets b/src/ext/Bal/test/examples/Directory.Build.targets index 35946585..b27a1a41 100644 --- a/src/ext/Bal/test/examples/Directory.Build.targets +++ b/src/ext/Bal/test/examples/Directory.Build.targets @@ -2,5 +2,6 @@ - + + diff --git a/src/ext/Bal/test/examples/Directory.csproj.props b/src/ext/Bal/test/examples/Directory.csproj.props new file mode 100644 index 00000000..e314ca20 --- /dev/null +++ b/src/ext/Bal/test/examples/Directory.csproj.props @@ -0,0 +1,5 @@ + + + + + diff --git a/src/ext/Bal/test/examples/Directory.wixproj.props b/src/ext/Bal/test/examples/Directory.wixproj.props new file mode 100644 index 00000000..78ad462f --- /dev/null +++ b/src/ext/Bal/test/examples/Directory.wixproj.props @@ -0,0 +1,11 @@ + + + + + Bundle + .exe + -generate payloadgroup + $(OutputPath)examples\ + None + + diff --git a/src/ext/Bal/test/examples/Directory.wixproj.targets b/src/ext/Bal/test/examples/Directory.wixproj.targets new file mode 100644 index 00000000..7e6fe9f2 --- /dev/null +++ b/src/ext/Bal/test/examples/Directory.wixproj.targets @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/ext/Bal/test/examples/DncBA.targets b/src/ext/Bal/test/examples/DncBA.targets new file mode 100644 index 00000000..2b8c1428 --- /dev/null +++ b/src/ext/Bal/test/examples/DncBA.targets @@ -0,0 +1,19 @@ + + + + + + + false + + + + + + + + + + diff --git a/src/ext/Bal/test/examples/EarliestCoreMBA/Example.EarliestCoreMBA.csproj b/src/ext/Bal/test/examples/EarliestCoreMBA/Example.EarliestCoreMBA.csproj index 8069df45..9b9f2bf6 100644 --- a/src/ext/Bal/test/examples/EarliestCoreMBA/Example.EarliestCoreMBA.csproj +++ b/src/ext/Bal/test/examples/EarliestCoreMBA/Example.EarliestCoreMBA.csproj @@ -3,15 +3,7 @@ netcoreapp3.1 win-x86;win-x64 - true + true Earliest .NET Core MBA - - - - - - - - diff --git a/src/ext/Bal/test/examples/LatestCoreMBA/Example.LatestCoreMBA.csproj b/src/ext/Bal/test/examples/LatestCoreMBA/Example.LatestCoreMBA.csproj index aad56a3e..a884fa07 100644 --- a/src/ext/Bal/test/examples/LatestCoreMBA/Example.LatestCoreMBA.csproj +++ b/src/ext/Bal/test/examples/LatestCoreMBA/Example.LatestCoreMBA.csproj @@ -3,18 +3,7 @@ net5.0 win-x86;win-x64 - true + true Latest .NET Core MBA - - - - - - - - - - - diff --git a/src/ext/Bal/test/examples/WPFCoreMBA/Example.WPFCoreMBA.csproj b/src/ext/Bal/test/examples/WPFCoreMBA/Example.WPFCoreMBA.csproj index 3d63e7b9..3186148b 100644 --- a/src/ext/Bal/test/examples/WPFCoreMBA/Example.WPFCoreMBA.csproj +++ b/src/ext/Bal/test/examples/WPFCoreMBA/Example.WPFCoreMBA.csproj @@ -3,22 +3,8 @@ net5.0-windows win-x86;win-x64 - true + true WPF .NET Core MBA true - - - - - - - - 42 - 42 - 42 - 42 - abc123def456 - - diff --git a/src/ext/Bal/test/examples/Wix.Build.props b/src/ext/Bal/test/examples/Wix.Build.props deleted file mode 100644 index 78ad462f..00000000 --- a/src/ext/Bal/test/examples/Wix.Build.props +++ /dev/null @@ -1,11 +0,0 @@ - - - - - Bundle - .exe - -generate payloadgroup - $(OutputPath)examples\ - None - - diff --git a/src/ext/Bal/test/examples/Wix.Build.targets b/src/ext/Bal/test/examples/Wix.Build.targets deleted file mode 100644 index 7e6fe9f2..00000000 --- a/src/ext/Bal/test/examples/Wix.Build.targets +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/src/ext/Bal/test/examples/examples.proj b/src/ext/Bal/test/examples/examples.proj index 5722cfcb..a16af2a4 100644 --- a/src/ext/Bal/test/examples/examples.proj +++ b/src/ext/Bal/test/examples/examples.proj @@ -17,14 +17,15 @@ $(MBAPublishPath)Example.EarliestCoreMBA + CopyUsed $(MBAPublishPath)Example.LatestCoreMBA + Link $(MBAPublishPath)Example.WPFCoreMBA true - true @@ -38,8 +39,8 @@ Condition="'%(CoreMBAProject.SkipFDD)'==''" /> - + diff --git a/src/ext/Bal/wixext/WixToolset.Bal.wixext.nuspec b/src/ext/Bal/wixext/WixToolset.Bal.wixext.nuspec index 4abfa98c..cdbb001c 100644 --- a/src/ext/Bal/wixext/WixToolset.Bal.wixext.nuspec +++ b/src/ext/Bal/wixext/WixToolset.Bal.wixext.nuspec @@ -7,7 +7,7 @@ $authors$ wix-white-bg.png MS-RL - https://github.com/wixtoolset/Bal.wixext + $projectUrl$ false $title$ $description$ diff --git a/src/ext/Bal/wixlib/BalExtension_platform.wxi b/src/ext/Bal/wixlib/BalExtension_platform.wxi index e1d846ce..b2750eee 100644 --- a/src/ext/Bal/wixlib/BalExtension_platform.wxi +++ b/src/ext/Bal/wixlib/BalExtension_platform.wxi @@ -8,7 +8,6 @@ - diff --git a/src/ext/Bal/wixlib/Dnc.wxs b/src/ext/Bal/wixlib/Dnc.wxs index d777c473..242bb30e 100644 --- a/src/ext/Bal/wixlib/Dnc.wxs +++ b/src/ext/Bal/wixlib/Dnc.wxs @@ -5,11 +5,6 @@ - - - - - diff --git a/src/internal/SetBuildNumber/Directory.Packages.props.pp b/src/internal/SetBuildNumber/Directory.Packages.props.pp index 6737cc38..675907e5 100644 --- a/src/internal/SetBuildNumber/Directory.Packages.props.pp +++ b/src/internal/SetBuildNumber/Directory.Packages.props.pp @@ -21,6 +21,7 @@ + @@ -45,6 +46,10 @@ + + + + diff --git a/src/test/burn/TestBA/TestBA.csproj b/src/test/burn/TestBA/TestBA.csproj index 183ea02d..7d51f4aa 100644 --- a/src/test/burn/TestBA/TestBA.csproj +++ b/src/test/burn/TestBA/TestBA.csproj @@ -21,4 +21,8 @@ + + + + diff --git a/src/test/burn/TestBA/TestBA_x64.csproj b/src/test/burn/TestBA/TestBA_x64.csproj index 8e2bf513..cb9db1c4 100644 --- a/src/test/burn/TestBA/TestBA_x64.csproj +++ b/src/test/burn/TestBA/TestBA_x64.csproj @@ -21,4 +21,8 @@ + + + + diff --git a/src/test/burn/TestData/TestBA/TestBAWixlib/testbawixlib.wixproj b/src/test/burn/TestData/TestBA/TestBAWixlib/testbawixlib.wixproj index fa153974..fdce5ecd 100644 --- a/src/test/burn/TestData/TestBA/TestBAWixlib/testbawixlib.wixproj +++ b/src/test/burn/TestData/TestBA/TestBAWixlib/testbawixlib.wixproj @@ -7,7 +7,7 @@ - + diff --git a/src/test/burn/TestData/TestBA/TestBAWixlib_x64/testbawixlib_x64.wixproj b/src/test/burn/TestData/TestBA/TestBAWixlib_x64/testbawixlib_x64.wixproj index 9bba3d8f..e63eb74c 100644 --- a/src/test/burn/TestData/TestBA/TestBAWixlib_x64/testbawixlib_x64.wixproj +++ b/src/test/burn/TestData/TestBA/TestBAWixlib_x64/testbawixlib_x64.wixproj @@ -8,7 +8,7 @@ - + diff --git a/src/test/burn/WixToolset.WixBA/WixToolset.WixBA.csproj b/src/test/burn/WixToolset.WixBA/WixToolset.WixBA.csproj index 2a2a0073..b872457c 100644 --- a/src/test/burn/WixToolset.WixBA/WixToolset.WixBA.csproj +++ b/src/test/burn/WixToolset.WixBA/WixToolset.WixBA.csproj @@ -2,7 +2,7 @@ - net45;net5.0-windows + net472;net5.0-windows WixToolset.WixBA WixToolset.WixBA embedded @@ -19,14 +19,14 @@ true - + - + @@ -37,4 +37,8 @@ + + + + \ No newline at end of file diff --git a/src/test/burn/WixToolset.WixBA/WixToolset.WixBA_x64.csproj b/src/test/burn/WixToolset.WixBA/WixToolset.WixBA_x64.csproj index bc1aa7bf..672f7a62 100644 --- a/src/test/burn/WixToolset.WixBA/WixToolset.WixBA_x64.csproj +++ b/src/test/burn/WixToolset.WixBA/WixToolset.WixBA_x64.csproj @@ -2,7 +2,7 @@ - net45;net5.0-windows + net472;net5.0-windows WixToolset.WixBA WixToolset.WixBA embedded @@ -19,14 +19,14 @@ true - + - + @@ -37,4 +37,8 @@ + + + + \ No newline at end of file diff --git a/src/testresultfilelist.txt b/src/testresultfilelist.txt index 97c698e6..20531e2d 100644 --- a/src/testresultfilelist.txt +++ b/src/testresultfilelist.txt @@ -12,6 +12,7 @@ build/logs/TestResults/WixToolsetTest.Core.trx build/logs/TestResults/WixToolsetTest.Core.Burn.trx build/logs/TestResults/WixToolsetTest.Core.Native.trx build/logs/TestResults/WixToolsetTest.CoreIntegration.trx +build/logs/TestResults/WixToolsetTest.Dnc.HostGenerator.trx build/logs/TestResults/WixToolsetTest.Heat.trx build/logs/TestResults/WixToolsetTest.Mba.Core.trx build/logs/TestResults/WixToolsetTest.Sdk.trx diff --git a/src/wix/WixToolset.Sdk/WixToolset.Sdk.csproj b/src/wix/WixToolset.Sdk/WixToolset.Sdk.csproj index bab6e9b7..b6751ed9 100644 --- a/src/wix/WixToolset.Sdk/WixToolset.Sdk.csproj +++ b/src/wix/WixToolset.Sdk/WixToolset.Sdk.csproj @@ -4,12 +4,10 @@ netcoreapp3.1 - false WiX Toolset MSBuild integration $(OutputPath)publish\WixToolset.Sdk\ $(MSBuildThisFileName).nuspec $(PublishDir) - Id=$(MSBuildThisFileName);Authors=$(Authors);Copyright=$(Copyright);Description=$(Description) -- cgit v1.2.3-55-g6feb