.Net Core 3.1 on Azure App Service

Thanks Microsoft! So it seems the MvcRazorCompileOnPublish project property is no longer supported or is not behaving properly with 3.0 and above, see https://github.com/dotnet/aspnetcore/issues/16688 for more details. The solution to this problem is as follows:

  1. Change MvcRazorCompileOnPublish to RazorCompileOnPublish in your web application project.
  2. Reference Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation is your project.
  3. In Startup.cs, add .AddRazorRuntimeCompilation() to services.AddMvc()
  4. Profit!