dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.54k stars 10.05k forks source link

ASP.NET Core 6 MVC CSS Isolation Breaks When RazorRuntimeCompilation Enabled #42411

Open jakenuts opened 2 years ago

jakenuts commented 2 years ago

Is there an existing issue for this?

Describe the bug

Enabling razor runtime compilation in an ASP.NET Core 6 MVC project prevents the CSS Isolation feature from generating css-scope attributes in Layout/View tags.

Expected Behavior

Razor runtime compilation should auto-generate the CSS Isolation attributes similarly to running without runtime compilation.

Steps To Reproduce

  1. In Visual Studio 2022 Professional create a new Asp.Net Core Wep App (Model-View-Controller) project.
  2. Run the project and view source
  3. Confirm tags in _Layout have auto-generated scope attributes and stop debugging
  4. Add the nuget package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation 6.0.6
  5. Update the environment variables section in your launchSettings.json file to this
 "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development",
        "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation"
      },
  1. Run the project again and view source
  2. Confirm that the auto generated scope attributes are no longer injected into the Layout tags

I understand this is probably a very complex problem to solve. But it leaves the developer with the choice of either using CSS Isolation (which is really cool) OR runtime compilation which is crucial for a good ASP.NET development experience.

Thanks,

James

Exceptions (if any)

No response

.NET Version

6.0.31

Anything else?

Reference to closed issue #33446:

ghost commented 2 years ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.