Merge pull request #18261 from dotnet-maestro-bot/merge/blazor-wasm-to-master
[automated] Merge branch 'blazor-wasm' => 'master'
This commit is contained in:
commit
7d8dd27d16
|
|
@ -0,0 +1,2 @@
|
||||||
|
<Project>
|
||||||
|
</Project>
|
||||||
|
|
@ -19,6 +19,11 @@ namespace Microsoft.AspNetCore.Blazor.Hosting
|
||||||
|
|
||||||
public WebAssemblyHost(IServiceProvider services, IJSRuntime runtime)
|
public WebAssemblyHost(IServiceProvider services, IJSRuntime runtime)
|
||||||
{
|
{
|
||||||
|
// To ensure JS-invoked methods don't get linked out, have a reference to their enclosing types
|
||||||
|
GC.KeepAlive(typeof(EntrypointInvoker));
|
||||||
|
GC.KeepAlive(typeof(JSInteropMethods));
|
||||||
|
GC.KeepAlive(typeof(WebAssemblyEventDispatcher));
|
||||||
|
|
||||||
Services = services ?? throw new ArgumentNullException(nameof(services));
|
Services = services ?? throw new ArgumentNullException(nameof(services));
|
||||||
_runtime = runtime ?? throw new ArgumentNullException(nameof(runtime));
|
_runtime = runtime ?? throw new ArgumentNullException(nameof(runtime));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System.IO;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
using Microsoft.Build.Framework;
|
||||||
|
using Microsoft.Build.Utilities;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNetCore.Blazor.Build.Tasks
|
||||||
|
{
|
||||||
|
public class GenerateTypeGranularityLinkingConfig : Task
|
||||||
|
{
|
||||||
|
[Required]
|
||||||
|
public ITaskItem[] Assemblies { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string OutputPath { get; set; }
|
||||||
|
|
||||||
|
public override bool Execute()
|
||||||
|
{
|
||||||
|
var linkerElement = new XElement("linker",
|
||||||
|
new XComment(" THIS IS A GENERATED FILE - DO NOT EDIT MANUALLY "));
|
||||||
|
|
||||||
|
foreach (var assembly in Assemblies)
|
||||||
|
{
|
||||||
|
var assemblyElement = CreateTypeGranularityConfig(assembly);
|
||||||
|
linkerElement.Add(assemblyElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
using var fileStream = File.Open(OutputPath, FileMode.Create);
|
||||||
|
new XDocument(linkerElement).Save(fileStream);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private XElement CreateTypeGranularityConfig(ITaskItem assembly)
|
||||||
|
{
|
||||||
|
// We match all types in the assembly, and for each one, tell the linker to preserve all
|
||||||
|
// its members (preserve=all) but only if there's some reference to the type (required=false)
|
||||||
|
return new XElement("assembly",
|
||||||
|
new XAttribute("fullname", Path.GetFileNameWithoutExtension(assembly.ItemSpec)),
|
||||||
|
new XElement("type",
|
||||||
|
new XAttribute("fullname", "*"),
|
||||||
|
new XAttribute("preserve", "all"),
|
||||||
|
new XAttribute("required", "false")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -22,8 +22,6 @@
|
||||||
<Target
|
<Target
|
||||||
Name="_BlazorCopyFilesToOutputDirectory"
|
Name="_BlazorCopyFilesToOutputDirectory"
|
||||||
DependsOnTargets="PrepareBlazorOutputs"
|
DependsOnTargets="PrepareBlazorOutputs"
|
||||||
Inputs="@(BlazorOutputWithTargetPath)"
|
|
||||||
Outputs="@(BlazorOutputWithTargetPath->'$(TargetDir)%(TargetOutputPath)')"
|
|
||||||
AfterTargets="CopyFilesToOutputDirectory"
|
AfterTargets="CopyFilesToOutputDirectory"
|
||||||
Condition="'$(OutputType.ToLowerInvariant())'=='exe'">
|
Condition="'$(OutputType.ToLowerInvariant())'=='exe'">
|
||||||
|
|
||||||
|
|
@ -160,6 +158,7 @@
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<UsingTask TaskName="BlazorILLink" AssemblyFile="$(BlazorTasksPath)" />
|
<UsingTask TaskName="BlazorILLink" AssemblyFile="$(BlazorTasksPath)" />
|
||||||
|
<UsingTask TaskName="GenerateTypeGranularityLinkingConfig" AssemblyFile="$(BlazorTasksPath)" />
|
||||||
|
|
||||||
<Target
|
<Target
|
||||||
Name="_LinkBlazorApplication"
|
Name="_LinkBlazorApplication"
|
||||||
|
|
@ -171,7 +170,10 @@
|
||||||
Outputs="$(_BlazorLinkerOutputCache)">
|
Outputs="$(_BlazorLinkerOutputCache)">
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<_BlazorDependencyAssembly Include="@(_BlazorDependencyInput)" IsLinkable="$([System.String]::Copy('%(FileName)').StartsWith('System.'))" />
|
<_BlazorDependencyAssembly Include="@(_BlazorDependencyInput)" />
|
||||||
|
<_BlazorDependencyAssembly IsLinkable="true" Condition="$([System.String]::Copy('%(Filename)').StartsWith('System.'))" />
|
||||||
|
<_BlazorDependencyAssembly IsLinkable="true" TypeGranularity="true" Condition="$([System.String]::Copy('%(Filename)').StartsWith('Microsoft.AspNetCore.'))" />
|
||||||
|
<_BlazorDependencyAssembly IsLinkable="true" TypeGranularity="true" Condition="$([System.String]::Copy('%(Filename)').StartsWith('Microsoft.Extensions.'))" />
|
||||||
|
|
||||||
<_BlazorAssemblyToLink Include="@(_WebAssemblyBCLAssembly)" />
|
<_BlazorAssemblyToLink Include="@(_WebAssemblyBCLAssembly)" />
|
||||||
<_BlazorAssemblyToLink Include="@(_BlazorDependencyAssembly)" Condition="'%(_BlazorDependencyAssembly.IsLinkable)' == 'true'" />
|
<_BlazorAssemblyToLink Include="@(_BlazorDependencyAssembly)" Condition="'%(_BlazorDependencyAssembly.IsLinkable)' == 'true'" />
|
||||||
|
|
@ -201,6 +203,15 @@
|
||||||
<_DotNetHostFileName Condition=" '$(OS)' == 'Windows_NT' ">dotnet.exe</_DotNetHostFileName>
|
<_DotNetHostFileName Condition=" '$(OS)' == 'Windows_NT' ">dotnet.exe</_DotNetHostFileName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<_TypeGranularityLinkingConfig>$(BlazorIntermediateOutputPath)linker.typegranularityconfig.xml</_TypeGranularityLinkingConfig>
|
||||||
|
</PropertyGroup>
|
||||||
|
<GenerateTypeGranularityLinkingConfig Assemblies="@(_BlazorAssemblyToLink->WithMetadataValue('TypeGranularity', 'true'))" OutputPath="$(_TypeGranularityLinkingConfig)" />
|
||||||
|
<ItemGroup>
|
||||||
|
<BlazorLinkerDescriptor Include="$(_TypeGranularityLinkingConfig)" />
|
||||||
|
<FileWrites Include="$(_TypeGranularityLinkingConfig)" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<BlazorILLink
|
<BlazorILLink
|
||||||
ILLinkPath="$(MonoLinkerPath)"
|
ILLinkPath="$(MonoLinkerPath)"
|
||||||
AssemblyPaths="@(_BlazorAssemblyToLink)"
|
AssemblyPaths="@(_BlazorAssemblyToLink)"
|
||||||
|
|
@ -257,6 +268,8 @@
|
||||||
<Output TaskParameter="Dependencies" ItemName="_BlazorResolvedRuntimeDependencies" />
|
<Output TaskParameter="Dependencies" ItemName="_BlazorResolvedRuntimeDependencies" />
|
||||||
</ResolveBlazorRuntimeDependencies>
|
</ResolveBlazorRuntimeDependencies>
|
||||||
|
|
||||||
|
<WriteLinesToFile File="$(_BlazorApplicationAssembliesCacheFile)" Lines="@(_BlazorResolvedRuntimeDependencies)" Overwrite="true" />
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<FileWrites Include="$(_BlazorApplicationAssembliesCacheFile)" />
|
<FileWrites Include="$(_BlazorApplicationAssembliesCacheFile)" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
<Project>
|
||||||
|
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\, Directory.Build.props))\Directory.Build.props" />
|
||||||
|
</Project>
|
||||||
|
|
@ -1,4 +1,10 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<BlazorProjectsRoot>$(RepoRoot)src\Components\Blazor\</BlazorProjectsRoot>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<Import Project="$(BlazorProjectsRoot)Blazor.Version.props" />
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
|
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
|
||||||
<IsShippingPackage>true</IsShippingPackage>
|
<IsShippingPackage>true</IsShippingPackage>
|
||||||
|
|
@ -18,8 +24,6 @@
|
||||||
MicrosoftEntityFrameworkCoreSqlServerPackageVersion=$(MicrosoftEntityFrameworkCoreSqlServerPackageVersion);
|
MicrosoftEntityFrameworkCoreSqlServerPackageVersion=$(MicrosoftEntityFrameworkCoreSqlServerPackageVersion);
|
||||||
MicrosoftAspNetCoreBlazorServerPackageVersion=$(MicrosoftAspNetCoreBlazorServerPackageVersion);
|
MicrosoftAspNetCoreBlazorServerPackageVersion=$(MicrosoftAspNetCoreBlazorServerPackageVersion);
|
||||||
</GeneratedContentProperties>
|
</GeneratedContentProperties>
|
||||||
|
|
||||||
<BlazorProjectsRoot>$(RepoRoot)src\Components\Blazor\</BlazorProjectsRoot>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue