In an asp.net core 2.0 project, I would like to force the publish of Views because I need them at runtime. Any clues?
Joe's answer is for .Net Core 2.
In .Net Core 3, if you are using the default services.AddControllersWithViews() in your Startup.cs then you need to use RazorCompileOnPublish.
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<RazorCompileOnPublish>false</RazorCompileOnPublish>
</PropertyGroup>
Also, if you need to enable Razor Runtime Compilation in Core 3, you require to install the "Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" package, then add the AddRazorRuntimeCompilation.
services.AddControllersWithViews()
.AddRazorRuntimeCompilation();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With