aspnetcore/breaking-changes/6/preservecompilationcontext-not-set-by-default.md
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 runtime compilation scenarios.
Prior to .NET 6, PreserveCompilationContext was set to true for all apps that target the Razor (Microsoft.NET.Sdk.Razor) and Web (Microsoft.NET.Sdk.Web) SDKs. Starting in .NET 6, this property is no longer configured by default. However, packages such as Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation configure this property as required.
ASP.NET Core 6.0
The dependency file contains compilation context.
The dependency file no longer contains compilation context.
This change improves build performance and startup time, and reduces the size of ASP.NET Core's build output.
If your app requires this feature and does not reference a package that configures the property, add the PreserveCompilationContext property to your project file.
<PropertyGroup>
<PreserveCompilationContext>true</PreserveCompilationContext>
</PropertyGroup>
None.
<!-- ## Category ASP.NET Core ## Affected APIs Not detectable via API analysis. -->