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:
- Change MvcRazorCompileOnPublish to RazorCompileOnPublish in your web application project.
- Reference Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation is your project.
- In Startup.cs, add .AddRazorRuntimeCompilation() to services.AddMvc()
- Profit!