diff options
| author | Rob Mensching <rob@firegiant.com> | 2024-01-11 18:26:20 -0800 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2024-03-06 18:03:38 -0800 |
| commit | 0d3d54992104288e9ee0c834d0b96e8502fd2d42 (patch) | |
| tree | 9efa49c4983cd2ba1becab64bd1f2faccac88acf /src/ext/Bal/WixToolset.Dnc.HostGenerator | |
| parent | 2824298d9dd817a47527c920363556b54ead5d5d (diff) | |
| download | wix-0d3d54992104288e9ee0c834d0b96e8502fd2d42.tar.gz wix-0d3d54992104288e9ee0c834d0b96e8502fd2d42.tar.bz2 wix-0d3d54992104288e9ee0c834d0b96e8502fd2d42.zip | |
Move the BootstrapperApplication out of proc
Diffstat (limited to 'src/ext/Bal/WixToolset.Dnc.HostGenerator')
5 files changed, 0 insertions, 200 deletions
diff --git a/src/ext/Bal/WixToolset.Dnc.HostGenerator/DncHostGenerator.cs b/src/ext/Bal/WixToolset.Dnc.HostGenerator/DncHostGenerator.cs deleted file mode 100644 index 088b2b49..00000000 --- a/src/ext/Bal/WixToolset.Dnc.HostGenerator/DncHostGenerator.cs +++ /dev/null | |||
| @@ -1,127 +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.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 | } | ||
diff --git a/src/ext/Bal/WixToolset.Dnc.HostGenerator/WixToolset.Dnc.HostGenerator.csproj b/src/ext/Bal/WixToolset.Dnc.HostGenerator/WixToolset.Dnc.HostGenerator.csproj deleted file mode 100644 index 750db40e..00000000 --- a/src/ext/Bal/WixToolset.Dnc.HostGenerator/WixToolset.Dnc.HostGenerator.csproj +++ /dev/null | |||
| @@ -1,27 +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>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 | <IncludeThisAssembly>true</IncludeThisAssembly> | ||
| 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> | ||
diff --git a/src/ext/Bal/WixToolset.Dnc.HostGenerator/WixToolset.Dnc.HostGenerator.nuspec b/src/ext/Bal/WixToolset.Dnc.HostGenerator/WixToolset.Dnc.HostGenerator.nuspec deleted file mode 100644 index 8f4de5e8..00000000 --- a/src/ext/Bal/WixToolset.Dnc.HostGenerator/WixToolset.Dnc.HostGenerator.nuspec +++ /dev/null | |||
| @@ -1,25 +0,0 @@ | |||
| 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 | <icon>wix.png</icon> | ||
| 10 | <license type="expression">MS-RL</license> | ||
| 11 | <requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
| 12 | <copyright>$copyright$</copyright> | ||
| 13 | <projectUrl>$projectUrl$</projectUrl> | ||
| 14 | <repository type="$repositorytype$" url="$repositoryurl$" commit="$repositorycommit$" /> | ||
| 15 | <dependencies> | ||
| 16 | <dependency id="WixToolset.Mba.Core" version="[$version$,5)" /> | ||
| 17 | </dependencies> | ||
| 18 | </metadata> | ||
| 19 | |||
| 20 | <files> | ||
| 21 | <file src="$projectFolder$\..\..\..\internal\images\wix.png" /> | ||
| 22 | <file src="$id$.dll" target="analyzers/dotnet/cs" /> | ||
| 23 | <file src="build\**\*" target="build" /> | ||
| 24 | </files> | ||
| 25 | </package> | ||
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 deleted file mode 100644 index f9306af7..00000000 --- a/src/ext/Bal/WixToolset.Dnc.HostGenerator/build/WixToolset.Dnc.HostGenerator.props +++ /dev/null | |||
| @@ -1,10 +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 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> | ||
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 deleted file mode 100644 index d536ef5f..00000000 --- a/src/ext/Bal/WixToolset.Dnc.HostGenerator/build/WixToolset.Dnc.HostGenerator.targets +++ /dev/null | |||
| @@ -1,11 +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 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> | ||
