.NET Core 3 support
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.
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
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.
Had the same issue for antiforgery after upgrading to asp.net 3.0 rc. Can anyone help? Thanks.
@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 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!
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?
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?
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
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.
I'd appreciate if someone sends a PR for 3.0, don't have time at all for this project for now
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.
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.
I also have this missing namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.NamespaceDirective
even with <PreserveCompilationReferences>true</PreserveCompilationReferences>
I finally used @whyseco version. https://www.nuget.org/packages/RazorLight.NetCore3/
@maxence51 giving this a test run. Thank you for sharing
@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.
Thanks @jsheetzati, I think this project deserves to be maintained.
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 I'd be happy to offer any assistance I could in maintaining the project.
I only have PR merge permission so far. Ivan would need to give me organization level role for me to add you.