使用asp.net核心发布视图 [英] Publish the Views with asp.net core

查看:49
本文介绍了使用asp.net核心发布视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在asp.net core 2.0项目中,我想强制发布View,因为我在运行时需要它们. 有任何线索吗?

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?

推荐答案

编辑your.csproj文件,并将PreserveCompilationContext添加为true,将MvcRazorCompileOnPublish添加为false

edit your.csproj file and add PreserveCompilationContext as true and MvcRazorCompileOnPublish as false

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
</PropertyGroup>

然后视图将包含在发布中

then views will be included in publish

从2.1版开始,无法使用

As of version 2.1 it is not possible to use Razor Class Libraries, and instead of embedding views they can be pre-compiled. Local views in the web app can still override views in the class library. In the new scenario you would remove the PreserveCompilationContext and MvcRazorCompileOnPublish settings and just use the default values. This way all views in the application will be pre-compiled and no .cshtml files will be included in the publish output.

这篇关于使用asp.net核心发布视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆