Skip to content

Scoped CSS is active in netcoreapp3.1 apps #27768

@stefanloerwald

Description

@stefanloerwald

Describe the bug

Even though scoped CSS is supposed to be a net5.0+ only feature, it is clearly (at least partially) active in projects targetting netcoreapp3.1.

To Reproduce

  1. dotnet new blazorserver -f netcoreapp3.1
  2. echo "" > foo.razor.css
  3. dotnet build

We would expect a build success without scoped CSS, as a file called foo.razor.css should have absolutely no effect.

However, we get the scoped-CSS-related error

error BLAZOR102: The scoped css file 'foo.razor.css' was defined but no associated razor component was found for it.

@javiercn identified the issue here in a GH discussion as originating from https://github.com/dotnet/aspnetcore/blob/master/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets#L76

Workaround until fix is available

As @javiercn mentioned, scoped CSS can simply be deactivated in affected projects by adding <ScopedCssEnabled>false</ScopedCssEnabled> to the csproj.

Metadata

Metadata

Assignees

No one assigned

    Labels

    affected-fewThis issue impacts only small number of customersarea-blazorIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.feature-css-isolationThis issue is related to CSS Isolation featurefeature-razor-sdkreevaluateWe need to reevaluate the issue and make a decision about itseverity-minorThis label is used by an internal tool

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions