ASP.NET Core App中project.json中build选项下的prepareCompilationContext的用途是什么? [英] What is the use of preserveCompilationContext under build option in project.json in ASP.NET Core App?

查看:58
本文介绍了ASP.NET Core App中project.json中build选项下的prepareCompilationContext的用途是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是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

描述如下:

preserveCompilationContext

类型:布尔值

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的用途是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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