RazorLight
RazorLight copied to clipboard
Razorlight dependency resolution fails in asp.net 4.7.2
Describe the bug When calling the RazorLight render methods from a .NET 4.7.2 Web project, it fails to resolve assemblies.
- Microsoft.AspNetCore.Html.Abstractions
- System.Immutable
- etc..
Every time one is fixed a new one arises.. Our system cannot use the packages specific to RazorLight as they are way outdated, so due to the references in RazorLight it cannot be used by Framework 4.7.2.
To Reproduce Create a NETSTANDARD2.0 project with razorlight and call it from a .net 7.7.2 asp.net web application.
I have a full repro on my github here: RazorLightTest
Expected behavior It renders a template.
Information (please complete the following information):
- OS: Windows10
- Platform .NET Framework 4.7.2
- RazorLight version [ e.g 2.0-beta8 ]
- Are you using the OFFICIAL RazorLight package? Yes
- Visual Studio version: 16.6.2
Additional context Hi @jzabroski :) As requested a full repro of this issue as simplified as i can. https://github.com/itniels/RazorLightTest
I started to clean up some scenarios related to legacy .NET Framework. In particular, in my local, I have added the fix suggested by someone in #202 . There are a couple of additional fixes needed to guard against spurious behavior on legacy .NET Framework, mostly dealing with making the .NET link-load process happy. End game is to evolve the API so users can more easily configure stuff that is currently hard-coded/inflexible, and then document the knobs. Defaults for knobs will target latest and greatest .NET 5.0.
@itniels Why do you have two lines for the same dependency?
https://github.com/itniels/RazorLightTest/blob/8f816632fbe3cac47e862c31211e1d0d155a081c/RazorLightTest/RazorEngine/RazorEngine.csproj#L30-L34
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor" Version="2.2.0" /> // DUPLICATE
<PackageReference Include="Microsoft.AspNetCore.Razor" Version="2.2.0" />
<PackageReference Include="RazorLight" Version="2.0.0-beta8" />
<!-- Here to satisfy intellisense -->
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor" Version="2.1.0" /> // DUPLICATE
@jzabroski Ahh so sorry, that was from testing! I updated it now to reflect what i used.
<ItemGroup>
<!-- RazorLight -->
<PackageReference Include="RazorLight" Version="2.0.0-beta8" />
<!-- Here to satisfy intellisense -->
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor" Version="2.1.0" />
</ItemGroup>
@itniels Were you able to work around this at all? We have a 4.7.2 project we'd like to use with RL, but ran into the same issue.
I think the fix is to have netstandard2.0 use the pre-FrameworkReference code. I'm still on vacation but will look into this next week. (FrameworkReference didn't exist until netstandard2.1 IIRC, as .NET Core pretty much only supported framework dependent deployment prior to intro of TFMs netstandard2.1/.netcoreapp3.0)
@itniels Were you able to work around this at all? We have a 4.7.2 project we'd like to use with RL, but ran into the same issue.
Hi @TheWrightDev, I did not no, we put the project on ice for a bit.
Hi, was there ever any progress on this? We're looking to use this on an Umbraco 8 project which requires 4.7.2 and I'm seeing the same error.
RIP Umbraco Developers
Didn't understand that last comment. Is Umbraco using RazorLight?
Edit: Nevermind, i see the person wanted to see about using it with Umbraco 8.
I think the fix is to have netstandard2.0 use the pre-FrameworkReference code. I'm still on vacation but will look into this next week. (FrameworkReference didn't exist until netstandard2.1 IIRC, as .NET Core pretty much only supported framework dependent deployment prior to intro of TFMs netstandard2.1/.netcoreapp3.0)
@toddams We had discussed this on our LinkedIn chat awhile ago - do you feel comfortable if we make this change?