Skip to content

Razor runtime view compilation via environment variable not working in .NET 6 #38465

Closed
@AndrewTriesToCode

Description

@AndrewTriesToCode

Runtime view compilation appears to not be working in .NET 6 Razor Pages projects when using the environment variable to specify this behavior as described here:

https://docs.microsoft.com/en-us/aspnet/core/mvc/views/view-compilation?view=aspnetcore-6.0&tabs=visual-studio#conditionally-enable-runtime-compilation-in-an-existing-project

If I manually add AddRazorRuntimeCompilation() in ConfigureServices it does work though.

I'm including v6.0.0 of the assembly package:
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.0" />

And my launch profile has the following section:

"environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development",
        "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation"
      }

Worked as expected in .NET 5 on the same project.

Metadata

Metadata

Assignees

Labels

area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesbugThis issue describes a behavior which is not expected - a bug.feature-mvc-razor-viewsFeatures related to the Razor view engine for Razor pages and MVC views

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions