What are buildOptions and preserveCompilationContext used for?
Asked Answered
I

3

16

I am playing with just released ASP.NET Core. I have created new project and I am looking at project.json. I'd like to know what is this part of configuration for:

"buildOptions": {
   "emitEntryPoint": true,
   "preserveCompilationContext": true
}
Intervale answered 10/7, 2016 at 22:9 Comment(0)
M
12

A good answer for emitEntryPoint exists here: What does compilationOptions.emitEntryPoint mean?

As for preserveCompilationContext the ASP.NET documentation states it needs to be true in order to compile views: https://docs.asp.net/en/latest/migration/rc1-to-rtm.html

Mistakable answered 10/7, 2016 at 23:41 Comment(0)
A
13

emitEntryPoint is used to let the compiler know it's an application, not a library. In other words, if emitEntryPoint = true, you must have a public static void Main().

From the docs:

Creates an executable if set to true, otherwise the project will produce a .dll.

preserveCompilationContext isn't documented in the above page (yet), but it's required when you are using Razor or any other type of runtime compiling. Without it, runtime compilation of Razor views will fail.

Asbestos answered 11/7, 2016 at 16:37 Comment(0)
M
12

A good answer for emitEntryPoint exists here: What does compilationOptions.emitEntryPoint mean?

As for preserveCompilationContext the ASP.NET documentation states it needs to be true in order to compile views: https://docs.asp.net/en/latest/migration/rc1-to-rtm.html

Mistakable answered 10/7, 2016 at 23:41 Comment(0)
W
0

In my case, ASP.NET Core 1.1,

"preserveCompilationContext": true

get build time in 9 seconds, after set false, build time get faster, ~1s.

My application is for Web Api only.

ref: issue version 1.1

Wingless answered 9/5, 2017 at 1:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.