在asp core 2.0项目中,我想强制发布View,因为我在运行时需要它们. 有任何线索吗?
In an asp 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版开始,无法使用 Razor类库,并且无需嵌入视图,而是可以对其进行预编译. Web应用程序中的本地视图仍然可以覆盖类库中的视图.在新方案中,您将删除PreserveCompilationContext和MvcRazorCompileOnPublish设置,而仅使用默认值.这样,应用程序中的所有视图都将被预编译,并且发布输出中将不包含.cshtml文件.
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核心发布视图
发布评论