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.
@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.
Ah some movement, I'll try to keep an eye on things and update FluentEmail as we go. Thanks for taking on the work!
馃悽
Upgraded in my local. Not yet tested, but it compiles. Huzzah!
Checkbox checked indicates resolved on my machine.
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_Testfails with
System.ArgumentException: An item with the same key has already been added. Key: namespace- [ ] RazorLightEngineTest
Ensure_Option_DisablEncoding_Renders_Models_Rawfails with
System.ArgumentException: An item with the same key has already been added. Key: namespace- [ ] RazorLightCompilerTest
Ensure_TemplateIsCompiled_ForExisting_ProjectItemfails 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
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.
@jzabroski this issue can now be closed.
@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 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鈥檛 used it yet. We鈥檙e 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.
And regarding the beta tag, I somewhere read a reason for it, but can鈥檛 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?
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.
@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.
Most helpful comment
@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.