Announcements icon indicating copy to clipboard operation
Announcements copied to clipboard

PreserveCompilationContext is no longer configured by default

Open pranavkm opened this issue 3 years ago • 1 comments

PreserveCompilationContext is no longer configured by default for ASP.NET Core apps targeting .NET 6 and newer

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 based scenarios.

Prior to .NET 6, PreserveCompilationContext was configured to true for all apps that target the Razor (Microsoft.NET.Sdk.Razor) and Web (Microsoft.NET.Sdk.Web) apps. Starting in .NET 6, this property is no longer configured by default. Packages such as Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation configure this property as required.

Version introduced

ASP.NET Core 6.0

Old behavior

Dependency file contains compilation context.

New behavior

Dependency file no longer contains compilation context.

Reason for change

This is part of our effort to improve build performance, startup time, and reduce the size of ASP.NET Core's build output.

Recommended action

If your app requires this feature and does not reference a package that configures this, update the project to include this property:

<PropertyGroup>
   <PreserveCompilationContext>true</PreserveCompilationContext>
</PropertyGroup>

Category

ASP.NET

Affected APIs

Not detectable via API analysis


Issue metadata

  • Issue type: breaking-change

pranavkm avatar Apr 08 '21 17:04 pranavkm

Please use https://github.com/dotnet/aspnetcore/issues/31622 for questions and further discussion.

pranavkm avatar Apr 08 '21 17:04 pranavkm