FluentEmail
FluentEmail copied to clipboard
Can't find Antiforgery package
When using FluentEmail it seems to work find for text emails, but when I try to use Templates. I get the following error when using .Net Core 3.1
Cannot find reference assembly 'Microsoft.AspNetCore.Antiforgery.dll' file for package Microsoft.AspNetCore.Antiforgery
Is this something that's already known about? Is there a workaround?
<PropertyGroup>
<PreserveCompilationReferences>true</PreserveCompilationReferences>
<PreserveCompilationContext>true</PreserveCompilationContext>
</PropertyGroup>
Add .csproj file
Out of curiosity, why does this fix the problem?
I only needed <PreserveCompilationReferences>true</PreserveCompilationReferences>
in my .NET 5 web application. Is an issue with RazorLight rather than FluentEmail afaik.
Could this be highlighted in the documentation? This took some time to find the solution.
This does not work in .NET 6
<PropertyGroup> <PreserveCompilationReferences>true</PreserveCompilationReferences> <PreserveCompilationContext>true</PreserveCompilationContext> </PropertyGroup>
Add .csproj file
For net 6 use:
<PropertyGroup>
<PreserveCompilationReferences>true</PreserveCompilationReferences>
<PreserveCompilationContext>true</PreserveCompilationContext>
<MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
<MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>
</PropertyGroup>
For net 6 use:
<PropertyGroup>
<PreserveCompilationReferences>true</PreserveCompilationReferences>
<PreserveCompilationContext>true</PreserveCompilationContext>
<MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
<MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>
</PropertyGroup>