.net core 3.0 + asp.net web api - code compiled but run time Error came
System.InvalidOperationException
HResult=0x80131509
Message=Cannot find reference assembly 'Microsoft.AspNetCore.Antiforgery.dll' file for package Microsoft.AspNetCore.Antiforgery
Source=Microsoft.Extensions.DependencyModel
StackTrace:
at Microsoft.Extensions.DependencyModel.Resolution.ReferenceAssemblyPathResolver.TryResolveAssemblyPaths(CompilationLibrary library, List1 assemblies)
at Microsoft.Extensions.DependencyModel.Resolution.CompositeCompilationAssemblyResolver.TryResolveAssemblyPaths(CompilationLibrary library, List1 assemblies)
at Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths(ICompilationAssemblyResolver resolver, List1 assemblies)
at Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths()
at System.Linq.Enumerable.SelectManySingleSelectorIterator2.MoveNext()
at RazorLight.Compilation.DefaultMetadataReferenceManager.Resolve(DependencyContext dependencyContext)
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 RazorLight.Compilation.TemplateFactoryProvider.
I have same issue. Installed Microsoft.AspNetCore.Antiforgery package and get error Cannot find reference assembly 'Microsoft.AspNetCore.Antiforgery.dll' file for package Microsoft.AspNetCore.Antiforgery.Reference. Any help appreciated. Thanks
Same here, I have tried to contact the developer. If someone can just let us know if this will be updated to handle .Net Core 3. I am willing to assist if I know this has a future and that someone else has not started on it already.
Attention: @toddams @smirnovp88 @chinnarao
I finally have a working solution upgraded to netcoreapp3. The solution has 3 new projects as well as a sample Postman collection under the samples directory.
There are a number of compiler warning and references to obsolete methods. I have not tried to fix those. If this code is accepted as a possible solution by @toddams then I will continue to help with the conversion of the code.
Please let me know what you think...
The one change I had to make in my consuming WebAPI project that might not be obvious from the source.
<PreserveCompilationReferences>true</PreserveCompilationReferences>
@jacodv do you happen to have a fork w commits to actually see the differences more easily?
@christophwille, I have a branch that I created from the cloned master. I tried to create a pull request without any success.
You mean you cloned this repo? Well pushing wouldn't work unless you were a member of the team here. That's why I asked about your fork into your account.
Nope, sorry. I cloned it. If I can get what I have into a fork, then I am willing to do it.
Fork the repo into your own account (on GH), and then add a new remote origin locally using git. That then allows you to take the data from the clone to your fork.
Cool, sounds like a plan. I will get to it in the morning. Thank you for the pointer...
@christophwille: Excuse my ignorance. I have pushed to this branch on my fork (https://github.com/jacodv/RazorLight/tree/branch_jdevil-UpgradeToNetCore3) I hope you can access it.
Yes, I can access it. To recap: updating the references + PreserveCompilationReferences is what did the trick in the end?
I see one issue here: 2.1 is the LTS, 2.2 goes out of support almost immediately when 3.0 ships. With those package changes it won't work for both 2.x and 3.0. (and PreserveCompilationReferences is ... strange)
fyi, I took a page from https://github.com/toddams/RazorLight/issues/248#issuecomment-499436254 and tried that myself at https://github.com/christophwille/myhaflinger.com/commit/2d1292fd2170078b2168f452ff3bbde0119c5f5e - those two lines make it work (note I had MvcRazorCompileOnPublish previously, so you'll have to try if that is necessary too)
@christophwille, just to be clear. You are using the current Nuget package 2.0.0-beta1 and you added the new project items and it worked?
Yes, the plain package from NuGet with those changes to the csproj.
Brilliant! Thank you.
ref https://github.com/aspnet/AspNetCore/issues/7966
I've created a RazorLight version for .NetCore 3.0 https://www.nuget.org/packages/RazorLight.NetCore3/ from https://github.com/whyseco/RazorLight
I experiment the same issue, has anyone solved this?
After some testing I found a solution.
I add the followinf line in the *.csproj and works with 2.0.-beta1 version
<PreserveCompilationReferences>true</PreserveCompilationReferences>
Hope help some one
@kYann a new RazorLight? Why?
This actualy repository is come to the die?