使用asp.net核心发布视图 [英] Publish the Views with asp.net core
问题描述
在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
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屋!