buildOptions 和 preserveCompilationContext 有什么用?
What are buildOptions and preserveCompilationContext used for?
我正在玩刚刚发布的ASP.NET核心。我创建了新项目,我正在查看 project.json
。我想知道这部分配置是什么:
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
}
emitEntryPoint 的一个很好的答案在这里:
至于 preserveCompilationContext,ASP.NET 文档指出它必须为真才能编译视图:https://docs.asp.net/en/latest/migration/rc1-to-rtm.html
emitEntryPoint 用于让编译器知道它是一个应用程序,而不是一个库。换句话说,如果emitEntryPoint = true
,你必须有一个public static void Main()
.
来自docs:
Creates an executable if set to true, otherwise the project will produce a .dll
.
preserveCompilationContext 未在上页中记录(尚未),但在使用 Razor 或任何其他类型的运行时编译时需要它。没有它,Razor 视图的运行时编译将失败。
就我而言,ASP.NET Core 1.1,
"preserveCompilationContext": true
在 9 秒内获得构建时间,设置为 false 后,构建时间变得更快,~1s。
我的应用程序仅适用于 Web Api。
我正在玩刚刚发布的ASP.NET核心。我创建了新项目,我正在查看 project.json
。我想知道这部分配置是什么:
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
}
emitEntryPoint 的一个很好的答案在这里:
至于 preserveCompilationContext,ASP.NET 文档指出它必须为真才能编译视图:https://docs.asp.net/en/latest/migration/rc1-to-rtm.html
emitEntryPoint 用于让编译器知道它是一个应用程序,而不是一个库。换句话说,如果emitEntryPoint = true
,你必须有一个public static void Main()
.
来自docs:
Creates an executable if set to true, otherwise the project will produce a
.dll
.
preserveCompilationContext 未在上页中记录(尚未),但在使用 Razor 或任何其他类型的运行时编译时需要它。没有它,Razor 视图的运行时编译将失败。
就我而言,ASP.NET Core 1.1,
"preserveCompilationContext": true
在 9 秒内获得构建时间,设置为 false 后,构建时间变得更快,~1s。
我的应用程序仅适用于 Web Api。