RazorLight icon indicating copy to clipboard operation
RazorLight copied to clipboard

.NET Core 3 support

Open jsheetzati opened this issue 7 years ago • 33 comments

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. https://github.com/aspnet/AspNetCore/issues/3756. The project also needs to target netcoreapp3.0 in order to use the FrameworkReference.

jsheetzati avatar Aug 20 '19 19:08 jsheetzati

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 avatar Aug 22 '19 02:08 jsheetzati

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.

springy76 avatar Sep 12 '19 12:09 springy76

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

zhangsquall avatar Sep 20 '19 04:09 zhangsquall

@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.

springy76 avatar Sep 20 '19 07:09 springy76

@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!

zhangsquall avatar Sep 21 '19 06:09 zhangsquall

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 avatar Sep 27 '19 18:09 joetherod

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?

joetherod avatar Sep 27 '19 18:09 joetherod

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

jsheetzati avatar Oct 02 '19 17:10 jsheetzati

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.

joetherod avatar Oct 02 '19 23:10 joetherod

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

toddams avatar Oct 03 '19 13:10 toddams

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.

alextof avatar Oct 11 '19 21:10 alextof

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.

jonny64bit avatar Oct 14 '19 10:10 jonny64bit

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

maxence51 avatar Oct 23 '19 14:10 maxence51

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

maxence51 avatar Oct 24 '19 08:10 maxence51

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

HamiltonManalo avatar Oct 30 '19 14:10 HamiltonManalo

@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.

jzabroski avatar Oct 30 '19 16:10 jzabroski

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

maxence51 avatar Oct 30 '19 20:10 maxence51

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.

jzabroski avatar Oct 30 '19 20:10 jzabroski

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

HamiltonManalo avatar Oct 31 '19 10:10 HamiltonManalo

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

jzabroski avatar Oct 31 '19 12:10 jzabroski