Load precompiled views binary from the bin directory
Work around for Assembly.Load in CoreCLR no longer loading arbitrary binaries from the bin directory.
This commit is contained in:
parent
268617ddba
commit
5820854940
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Microsoft.AspNetCore.Mvc.ApplicationParts;
|
using Microsoft.AspNetCore.Mvc.ApplicationParts;
|
||||||
|
|
@ -56,6 +57,23 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Compilation
|
||||||
/// <returns>The <see cref="ViewInfoContainer"/> <see cref="Type"/>.</returns>
|
/// <returns>The <see cref="ViewInfoContainer"/> <see cref="Type"/>.</returns>
|
||||||
protected virtual Type GetViewInfoContainerType(AssemblyPart assemblyPart)
|
protected virtual Type GetViewInfoContainerType(AssemblyPart assemblyPart)
|
||||||
{
|
{
|
||||||
|
#if NETSTANDARD1_6
|
||||||
|
if (assemblyPart.Assembly.Location != null)
|
||||||
|
{
|
||||||
|
var precompiledAssemblyFileName = assemblyPart.Assembly.GetName().Name
|
||||||
|
+ PrecompiledViewsAssemblySuffix
|
||||||
|
+ ".dll";
|
||||||
|
var precompiledAssemblyFilePath = Path.Combine(
|
||||||
|
assemblyPart.Assembly.Location,
|
||||||
|
precompiledAssemblyFileName);
|
||||||
|
|
||||||
|
if (File.Exists(precompiledAssemblyFilePath))
|
||||||
|
{
|
||||||
|
System.Runtime.Loader.AssemblyLoadContext.Default.LoadFromAssemblyPath(precompiledAssemblyFilePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
var precompiledAssemblyName = new AssemblyName(assemblyPart.Assembly.FullName);
|
var precompiledAssemblyName = new AssemblyName(assemblyPart.Assembly.FullName);
|
||||||
precompiledAssemblyName.Name = precompiledAssemblyName.Name + PrecompiledViewsAssemblySuffix;
|
precompiledAssemblyName.Name = precompiledAssemblyName.Name + PrecompiledViewsAssemblySuffix;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue