问题描述
我是ASP.NET Core的新手.我试图了解project.json中的各种选项.但是无法理解project.json中构建选项下的 preserveCompilationContext:true 的含义.根据Microsoft 文档
I am new to ASP.NET Core. I am trying to understand various options in project.json. But could not understand the meaning of preserveCompilationContext:true under build options in project.json. According to the microsoft documentation
描述如下:
true,保留参考程序集和其他上下文数据,以允许运行时编译;否则为假
true to preserve reference assemblies and other context data to allow for runtime compilation; otherwise, false
提前谢谢
推荐答案
据我所知,这主要用于Razor页面.它们在运行时进行编译,并且编译器需要访问参考程序集,以确保其正确编译.因此,要使用Razor页面,您需要设置 preserveCompilationContext
,然后在发布的输出中包括所有必需的文件.
As far as I know, this is primarily used for Razor pages. They are compiled at runtime, and the compiler needs access to reference assemblies, to make sure it compiles correctly. So, to use Razor pages, you need to set preserveCompilationContext
, which then includes all the necessary files in the published output.
如果不需要运行时编译,则不必设置 preserveCompilationContext
.
If you don't need runtime compilation, you don't have to set preserveCompilationContext
.
这篇关于ASP.NET Core App中project.json中build选项下的prepareCompilationContext的用途是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!