Publish the Views with asp.net core

后端 未结 2 748
执笔经年
执笔经年 2020-12-25 08:26

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?

2条回答
  •  北海茫月
    2020-12-25 09:02

    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.

      
        netcoreapp3.1
        true
        false
      
    

    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();
    

提交回复
热议问题