Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not compatible with Microsoft.AspNetCore.Razor 2.0.0 #486

Closed
0x53A opened this issue Sep 3, 2017 · 15 comments
Closed

Not compatible with Microsoft.AspNetCore.Razor 2.0.0 #486

0x53A opened this issue Sep 3, 2017 · 15 comments

Comments

@0x53A
Copy link

0x53A commented Sep 3, 2017

Microsoft.AspNetCore.Razor 2.0.0 only contains a netstandard2.0 dll with a few types:

image

This obviously causes RazorEngine to crash.

I would suggest to change the reference to 1.0 <= x < 2.0 and/or inquire with the asp.net team if this was on purpose and where the types moved.

@matthid
Copy link
Collaborator

matthid commented Sep 3, 2017

/cc @conniey

@nvivo
Copy link

nvivo commented Sep 7, 2017

While this is not resolved, I'm leaving this workaround if someone needs it.

I was able to keep RazorEngine working on my app after upgrading to aspnet core 2.0 by using ILMerge-GUI + ILRepack to merge and internalize it's dependencies:

image

Just remove the nuget reference and add the reference to the new file instead. Not perfect, but prevented me from downgrading a dozen projects due to a single dependency.

@hermanho
Copy link

hermanho commented Sep 22, 2017

It seems that a breaking changes had made.
aspnet/Announcements#227
aspnet/Razor#1084

Would it work when you include Microsoft.AspNetCore.Razor, Microsoft.AspNetCore.Razor.Runtime and
Microsoft.AspNetCore.Razor.Language for netstandard2.0 ?

@mscrivo
Copy link

mscrivo commented Oct 11, 2017

I've tried adding those 2 extra packages, but still getting this error:

Exception="System.TypeLoadException" ExceptionDetail="System.TypeLoadException: Could not load type 'Microsoft.AspNetCore.Razor.Parser.ParserBase' from assembly 'Microsoft.AspNetCore.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

with RazorEngine 4.5.1-alpha001

@GetTaxSolutions
Copy link

We also have some problem. Will it be fixed soon?

@daviatorstorm
Copy link

image

@conniey
Copy link
Contributor

conniey commented Dec 18, 2017

@daviatorstorm Hi, the reason you are getting that issue is because an ASP.NET Core application (netcoreapp2.0) does not support System.Configuration. If you used a full Framework ASP.NET application, it would resolve correctly.
The package currently available on NuGet.org does not run on .NET Core yet.

@conniey
Copy link
Contributor

conniey commented Dec 19, 2017

@0x53A Can you give me a repro of the issue you're having? I am able to get my package, built from #488 to run and work on my ASP.NET Full .NET Framework application.

@0x53A
Copy link
Author

0x53A commented Dec 19, 2017

@conniey I don't have a standalone repo, but will describe my use case a bit more:

  • F# fsx script that uses RazorEngine to generate files from templates
  • I added a reference to RazorEngine through paket
  • Microsoft.AspNetCore.Razor is pulled in as an implicit dependency, no other Asp.net projects are used in this context.

Now the issue is that between 1.x and 2.x, most classes were removed from Microsoft.AspNet.Razor.dll, as you can see in my first screenshot.

This causes a typeload exception at runtime.

I fixed the issue by pinning Microsoft.AspNetCore.Razor < 2.0 in my paket.dependencies.

@conniey
Copy link
Contributor

conniey commented Dec 19, 2017

@0x53A Thanks for explaining the issue! I asked the ASP.NET team and when we move to .NET Core, I'll have to add those extra dependencies they mention here: aspnet/Razor#1855 (comment)

Your current workaround is what I applied to #488 for now.

@nvivo
Copy link

nvivo commented Feb 2, 2018

@matthid Any chance we can get a new release with this support?

@conniey
Copy link
Contributor

conniey commented Feb 2, 2018

@nvivo hey, I had looked into this when it was first mentioned. However, they've upgraded, deprecated, and made internal many classes that RazorEngine uses. So it'll be a huge undertaking. I can look into it more over the weekend but no promises.

@nvivo
Copy link

nvivo commented Feb 2, 2018

@conniey Right. I thought #488 was solving this issue, as it was closed by it. So, it's being abandoned for now?

@conniey
Copy link
Contributor

conniey commented Feb 2, 2018

@nvivo #488 explicitly says we should use a version less than 2.0.0 for RazorEngine. Adding support for Microsoft.AspNetCore.Razor 2.0.0 would be another issue

@nvivo
Copy link

nvivo commented Feb 2, 2018

Sorry, I didn't read all the PR, just saw it closed this one. My fault.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants