Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AddRazorRuntimeCompilation causing deployment problems

When I try to deploy my project it fails with the following message:-

Startup.cs(75,25): error CS1061: 'IMvcBuilder' does not contain a definition for 'AddRazorRuntimeCompilation' 
and no accessible extension method 'AddRazorRuntimeCompilation' accepting a first argument of type 'IMvcBuilder' 
could be found (are you missing a using directive or an assembly reference?)

I found an answer here How to fix 'IMvcBuilder' doesn't contain a definition for 'AddXmlDataContractSerializerFormatters' however after installing the suggested MVC formatter package(s) The issue persisted.

The only way I have been able to deploy is to comment out the following lines in my startup class

var builder = services.AddRazorPages();
if (Env.IsDevelopment())
{
    builder.AddRazorRuntimeCompilation();
}

Maybe I need to update something on the deployment server? It is the organisation's first DotNet Core 3.1 application

like image 937
Ar77 Avatar asked Jul 21 '26 10:07

Ar77


1 Answers

You need to install Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation, but not the latest version. Something compatible with .Net Core 3.x.

E.g.

Package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation 3.1.19

like image 176
Cameron Castillo Avatar answered Jul 23 '26 00:07

Cameron Castillo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!