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

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

问题描述

我是 ASP.NET Core 的新手.我试图了解 project.json 中的各种选项.但是无法理解 project.json 中构建选项下 preserveCompilationContext:true 的含义.根据微软文档

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

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