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
it is described as follows:
preserveCompilationContext
Type: Boolean
true to preserve reference assemblies and other context data to allow for runtime compilation; otherwise, false
Thank you in advance
PreserveCompilationContext is an MSBuild property that causes . NET Core projects to emit additional content to the application's dependency (. deps) file about how the app was compiled. This is primarily used to support run-time compilation scenarios.
deps. json will mean the host will blindly enumerate all . dll files in the application directory and use those as the "entire app". This typically means: Portable apps may not work (building with no RID specified will produce a portable app)
In ASP.NET Core project. json is used for project metadata, compilation information, and dependencies. When used in other project systems, those three things are split into separate files and project.
deps. json'. This file is required for functional tests to run properly. There should be a copy of the file on your source project bin folder.
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.
If you don't need runtime compilation, you don't have to set preserveCompilationContext
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With