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

.NET Core 3 support #267

Closed
jsheetzati opened this issue Aug 20, 2019 · 33 comments
Closed

.NET Core 3 support #267

jsheetzati opened this issue Aug 20, 2019 · 33 comments

Comments

@jsheetzati
Copy link

Is your feature request related to a problem? Please describe.
Add full ASP.NET Core 3 support.

Describe the solution you'd like
Most of the used Microsoft.AspNetCore.* nuget packages are encompassed into the FrameworkReference and no longer available as Nuget packages. dotnet/aspnetcore#3756. The project also needs to target netcoreapp3.0 in order to use the FrameworkReference.

@jsheetzati
Copy link
Author

I should be able to open a PR once .NET Core 3 comes out of preview. Updated the project to support netstandard2.0 as well as netcoreapp3.0

@springy76
Copy link

springy76 commented Sep 12, 2019

I just updated a blazor-server app which uses RazorLight from netcore 3.0-preview8 to 3.0-preview9 -- that app itself has gone successfully through all previews of netcore 3.0 of the last 10 months.

Now out of a sudden I can't use RazorLight anymore, I just get an InvalidOperationException "Cannot find reference assembly 'Microsoft.AspNetCore.Antiforgery.dll' file for package Microsoft.AspNetCore.Antiforgery.Reference" at public Task<string> CompileRenderAsync<T>(string key, T model, ExpandoObject viewBag = null):

   at Microsoft.Extensions.DependencyModel.Resolution.ReferenceAssemblyPathResolver.TryResolveAssemblyPaths(CompilationLibrary library, List`1 assemblies)
   at Microsoft.Extensions.DependencyModel.Resolution.CompositeCompilationAssemblyResolver.TryResolveAssemblyPaths(CompilationLibrary library, List`1 assemblies)
   at Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths(ICompilationAssemblyResolver resolver, List`1 assemblies)
   at Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths()
   at RazorLight.Compilation.DefaultMetadataReferenceManager.<>c.<Resolve>b__6_0(CompilationLibrary library)
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at RazorLight.Compilation.DefaultMetadataReferenceManager.Resolve(DependencyContext dependencyContext)
   at RazorLight.Compilation.DefaultMetadataReferenceManager.Resolve(Assembly assembly)
   at RazorLight.Compilation.RoslynCompilationService.EnsureOptions()
   at RazorLight.Compilation.RoslynCompilationService.get_ParseOptions()
   at RazorLight.Compilation.RoslynCompilationService.CreateSyntaxTree(SourceText sourceText)
   at RazorLight.Compilation.RoslynCompilationService.CreateCompilation(String compilationContent, String assemblyName)
   at RazorLight.Compilation.RoslynCompilationService.CompileAndEmit(IGeneratedRazorTemplate razorTemplate)
   at RazorLight.Compilation.RoslynCompilationService.CompileAsync(IGeneratedRazorTemplate razorTemplate)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at RazorLight.Compilation.TemplateFactoryProvider.<CompileAsync>d__10.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at RazorLight.Compilation.TemplateFactoryProvider.<CreateFactoryAsync>d__8.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at RazorLight.RazorLightEngine.<CompileTemplateAsync>d__14.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at RazorLight.RazorLightEngine.<CompileRenderAsync>d__11.MoveNext()```

I never had used or referenced Antiforgery before. Even adding a reference to `Microsoft.AspNetCore.Antiforgery` to the project did not change anything.

@zhangsquall
Copy link

Had the same issue for antiforgery after upgrading to asp.net 3.0 rc. Can anyone help?
Thanks.

@springy76
Copy link

@zhangsquall for me adding <PreserveCompilationReferences>true</PreserveCompilationReferences> to the project file solved the problem. Please don't ask me which side-effects this may introduce.

@zhangsquall
Copy link

@zhangsquall for me adding <PreserveCompilationReferences>true</PreserveCompilationReferences> to the project file solved the problem. Please don't ask me which side-effects this may introduce.

It worked!

@joetherod
Copy link

joetherod commented Sep 27, 2019

Eta for new release that works with ,NET Core 3.0? Namespace missing in 3.0:
Microsoft.AspNetCore.Mvc.Razor.Extensions.NamespaceDirective
3.0 is RTM.
Eta for new release?

@joetherod
Copy link

I should be able to open a PR once .NET Core 3 comes out of preview. Updated the project to support netstandard2.0 as well as netcoreapp3.0

@jsheetzati 3.0 is RTM. Eta for PR approval?

@jsheetzati
Copy link
Author

jsheetzati commented Oct 2, 2019

Changes are in this branch with latest .NET Core 3 packages. I have not had an opportunity to verify the RTM packages work without additional changes yet.

https://github.com/altriadeveloper/RazorLight/tree/spike-netcore3squashed

@joetherod
Copy link

I pulled master and got it to compile with 3.0, but a lot of tests failed. I didnt try this PR.
I went with https://github.com/aspnet/Entropy/blob/master/samples/Mvc.RenderViewToString/RazorViewToStringRenderer.cs

I extended it to support what I needed. Cleaner and works with Core 3.0.

Repository owner deleted a comment from kYann Oct 3, 2019
@toddams
Copy link
Owner

toddams commented Oct 3, 2019

I'd appreciate if someone sends a PR for 3.0, don't have time at all for this project for now

@alextof
Copy link

alextof commented Oct 11, 2019

Someone is able to make RazorViewToStringRenderer.cs work with .NET Core 3.0 getting the views from a Razor UI Class Library? Was working on 2.0, 2.1 and 2.2, now not anymore, IRazorViewEngine does not find the view.

@jonny64bit
Copy link

Just to confirm i've been using <PreserveCompilationReferences>true</PreserveCompilationReferences>
for a while pre .net core 3 being released and never expiranced any issues with it.

@maxence51
Copy link

I also have this missing namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.NamespaceDirective
even with <PreserveCompilationReferences>true</PreserveCompilationReferences>

@maxence51
Copy link

I finally used @whyseco version. https://www.nuget.org/packages/RazorLight.NetCore3/

@HamiltonManalo
Copy link
Contributor

@maxence51 giving this a test run. Thank you for sharing

@jzabroski
Copy link
Collaborator

@maxence51 I'm planning to merge together various fixes for RazorLight. I just got PR access last week from @toddams . I have another project I'm helping out with on top of my day job.

@maxence51
Copy link

Thanks @jsheetzati, I think this project deserves to be maintained.

@jzabroski
Copy link
Collaborator

Yeah, my vision is that RazorLight will support FluentMigrator 4.0.0 release as well as possibly help Dave Gleick's Wyam and Statiq projects to replace the antiquated DocFX maintained by Microsoft, in addition to the core use case of @bjcull Ben Cull's FluentEmail project.

@HamiltonManalo
Copy link
Contributor

@jzabroski
I'd be happy to offer any assistance I could in maintaining the project.

@jzabroski
Copy link
Collaborator

I only have PR merge permission so far. Ivan would need to give me organization level role for me to add you.

@bjcull
Copy link

bjcull commented Nov 1, 2019

Ah some movement, I'll try to keep an eye on things and update FluentEmail as we go. Thanks for taking on the work!

@jzabroski
Copy link
Collaborator

🐢

@jzabroski
Copy link
Collaborator

jzabroski commented Nov 4, 2019

Upgraded in my local. Not yet tested, but it compiles. Huzzah!

Failing Tests (8 of 135)

Checkbox checked indicates resolved on my machine.

  • PropertyInjectorTest Ensure_Registered_Properties_Are_Injected fails with

    System.ArgumentException : An item with the same key has already been added. Key: namespace

  • RaceConditionTests Multiple_Simuntaneous_Compilations_RaceCondition_Test fails with

    System.ArgumentException : An item with the same key has already been added. Key: namespace

  • RazorLightEngineTest Ensure_Option_DisablEncoding_Renders_Models_Raw fails with

    System.ArgumentException : An item with the same key has already been added. Key: namespace

  • RazorLightCompilerTest Ensure_TemplateIsCompiled_ForExisting_ProjectItem fails with

    System.ArgumentException : An item with the same key has already been added. Key: namespace

  • TemplateRendererTest 4 failures: (1) Template_Shares_Model_With_Layout (2) Templates_Supports_Conditional_Attribute_Rendering (3) Templates_Supports_Local_Functions (4) Templates_Supports_Local_Functions_Using_Helper

My notes:

  • Main issue appears to be the InstrumentationPass helper is now gone.

My questions:

  • I didn't try to get this to work side-by-side between 2.x and 3.y. e.g. I think RazorLight for ASP.NET Core 3.z should ship as RazorLight 3.y
  • For all intents and purposes, I think most people don't expect a ton of active development in 2.x packages and expect this project to be maintained in GitFlow-style. However, the next week or so is time for people to Speak Now Or Forever Hold Your Peace.
  • I'm confused by Error due to NamespaceDirective use on .NET Core 3.0 #273 which says NamespaceDirective is removed, but the code compiles fine after I upgraded. Is

@HamiltonManalo
Copy link
Contributor

I would be okay with a package being versioned for 2x and 3.y as I don't expect to revert back to 2.0 anytime though.

@gjunge
Copy link
Contributor

gjunge commented Nov 27, 2019

@jzabroski this issue can now be closed.

@jzabroski
Copy link
Collaborator

@gjunge Thanks for all your help! Let me know if you encounter and issues. At some point we should probably drop the beta tag.

@gjunge
Copy link
Contributor

gjunge commented Nov 28, 2019

@gjunge Thanks for all your help! Let me know if you encounter and issues. At some point we should probably drop the beta tag.

Happy to help. The truth to be told is that I currently not use the project and haven’t used it yet. We’re moving our projects from full framework to .NET Core, and in one of those projects we use some other Razor library which is not .NET Standard compatible, and that is why I came here and wanted to help with that .NET Core 3 support.

@gjunge
Copy link
Contributor

gjunge commented Nov 28, 2019

And regarding the beta tag, I somewhere read a reason for it, but can’t remember where/why.
And yes it is time to drop it soon.

However I also thought of nice Microsoft DI support, would that be something that fits in the vision of the project?

@DanielToft
Copy link

Is this released? On version 2.0.0-beta2, i'm still getting "Cannot find reference assembly 'Microsoft.AspNetCore.Antiforgery.dll'" when using "UseFileSystemProject". When i use "UseEmbeddedResourcesProject" it cannot find my templates.

@jzabroski
Copy link
Collaborator

@DanielToft Please open a new issue and file a bug report. Yes, .NET Core 3 support is released - you can see that from nuget.org dependencies accordian.

@billbrinck
Copy link

Is this released? On version 2.0.0-beta2, i'm still getting "Cannot find reference assembly 'Microsoft.AspNetCore.Antiforgery.dll'" when using "UseFileSystemProject". When i use "UseEmbeddedResourcesProject" it cannot find my templates.

Same for me. It can't find my templates. Did you resolve this somehow?

@jzabroski
Copy link
Collaborator

@billbrinck Please open a new issue and file a bug report with repro steps. Alternatively, look at the example in the source and look at what could be different between your project and this one.

@jzabroski
Copy link
Collaborator

I see that you did create a discussion here: #452

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