You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
RazorLight cannot be used in an application that has been merged into a single assembly using ILMerge. ILMerge combines all referenced assemblies into one. This has the side-effect of changing the assembly name for all types that have been merged. So, when the OverrideRuntimeNodeWriterTemplateTypeNamePhase attempts to locate the Microsoft.AspNetCore.Razor.Language.DefaultRazorCSharpLoweringPhase type in the Register method, it fails because the AssemblyQualifiedName for that type no longer contains "Microsoft.AspNet.Core.Razor.Language" as the assembly name. The result is that OverrideRuntimeNodeWriterTemplateTypeNamePhase.Register throws a RazorLightException with the error "SetTemplateTypePhase cannot be registered as DefaultRazorCSharpLoweringPhase could not be located".
To Reproduce
Create a console application for .Net Framework 4.8 using RazorLight. I used the RazorLightSandbox and updated the async using statements in Main() to comply with C#7.3.
Install the ILMerge.MSBuild.Task package (see https://github.com/emerbrito/ILMerge-MSBuild-Task/wiki)
Compile the project. There should be an ILMerge directory in the output.
Run the generated executable.
You should see the error
Exception
System.AggregateException: One or more errors occurred. ---> RazorLight.RazorLightException: SetTemplateTypePhase cannot be registered as DefaultRazorCSharpLoweringPhase could not be located
at RazorLight.Instrumentation.OverrideRuntimeNodeWriterTemplateTypeNamePhase.Register(RazorProjectEngineBuilder builder)
at RazorLight.DefaultRazorEngine.<>c__DisplayClass1_0.<get_Instance>b__0(RazorProjectEngineBuilder builder)
at Microsoft.AspNetCore.Razor.Language.RazorProjectEngine.Create(RazorConfiguration configuration, RazorProjectFileSystem fileSystem, Action`1 configure)
at RazorLight.DefaultRazorEngine.get_Instance()
at RazorLight.RazorLightEngineBuilder.Build()
Expected behavior
The library should be usable in an assembly that has been merged with ILMerge.
Information (please complete the following information):
Visual Studio version: Visual Studio Pro [ e.g Visual Studio Community 17.8.5 ]
Additional context
The application that this applies to is a portable tool used by our development team to create API documentation. The tool must be a single executable with all dependencies "wrapped in". Unfortunately, other dependencies of this tool are still targeting the .Net Framework v4.8.
The text was updated successfully, but these errors were encountered:
ILMerge utility is not supported and I don't recall any plans to support it. Considering that it has been deprecated, I'm closing this one as "won't do"
Describe the bug
RazorLight cannot be used in an application that has been merged into a single assembly using ILMerge. ILMerge combines all referenced assemblies into one. This has the side-effect of changing the assembly name for all types that have been merged. So, when the
OverrideRuntimeNodeWriterTemplateTypeNamePhase
attempts to locate theMicrosoft.AspNetCore.Razor.Language.DefaultRazorCSharpLoweringPhase type
in theRegister
method, it fails because theAssemblyQualifiedName
for that type no longer contains "Microsoft.AspNet.Core.Razor.Language" as the assembly name. The result is thatOverrideRuntimeNodeWriterTemplateTypeNamePhase.Register
throws a RazorLightException with the error "SetTemplateTypePhase cannot be registered as DefaultRazorCSharpLoweringPhase could not be located".See also #322
To Reproduce
Create a console application for .Net Framework 4.8 using RazorLight.
I used the RazorLightSandbox and updated the async using statements in Main() to comply with C#7.3.Install the ILMerge.MSBuild.Task package (see https://github.com/emerbrito/ILMerge-MSBuild-Task/wiki)
Compile the project. There should be an ILMerge directory in the output.
Run the generated executable.
You should see the error
Expected behavior
The library should be usable in an assembly that has been merged with ILMerge.
Information (please complete the following information):
Additional context
The application that this applies to is a portable tool used by our development team to create API documentation. The tool must be a single executable with all dependencies "wrapped in". Unfortunately, other dependencies of this tool are still targeting the .Net Framework v4.8.
The text was updated successfully, but these errors were encountered: