1

I installed in my project RazorLight. It work fine locally, but when I build it in release mode this is the error:

Cannot find reference assembly 'Microsoft.AspNetCore.Antiforgery.dll' file for package Microsoft.AspNetCore.Antiforgery System.InvalidOperationException: Cannot find reference assembly 'Microsoft.AspNetCore.Antiforgery.dll' file for package Microsoft.AspNetCore.Antiforgery

I already did what documentation says, so I changed my *.csproj in this way:

<PropertyGroup>
    <TargetFramework>net7.0</TargetFramework>
    <CopyRefAssembliesToPublishDirectory>false</CopyRefAssembliesToPublishDirectory>
    <MvcBuildViews>true</MvcBuildViews>
    <PreserveCompilationReferences>true</PreserveCompilationReferences>
    <PreserveCompilationContext>true</PreserveCompilationContext>
</PropertyGroup>

PreserveCompilationReferences and PreserveCompilationContext don't seem to work. .Net 7.0 could be the problem?

In program I also have this line of code:

builder.Services.AddRazorPages().AddRazorRuntimeCompilation();

Where could be the issue?

erikscandola
  • 2,854
  • 2
  • 17
  • 24

0 Answers0