Skip to content

Blazor Hybrid MAUI unpackaged single-file apps do not extract Application.styles.css (scoped CSS) at runtime #33587

@Abdulrhman5

Description

@Abdulrhman5

Description

When publishing a .NET 10 MAUI Blazor Hybrid application as an unpackaged, self-contained, single-file Windows executable, the generated Blazor scoped CSS bundle (.styles.css) is not extracted at runtime, even though it is present in the publish output.

This results in missing styles at runtime because BlazorWebView expects the scoped CSS bundle (.styles.css) to be present under wwwroot in the runtime extraction directory (%LOCALAPPDATA%\Temp.net<AppName><hash>\wwwroot), but the file is not extracted there when running the single-file executable. I am not sure the CSS file is even included in the single-file executable.

This appears to be an interaction issue between:

  • Razor scoped CSS static web assets
  • MAUI Blazor Hybrid
  • .NET single-file bundling/extraction

##Expected Behavior##

The runtime extraction directory (%LOCALAPPDATA%\Temp\.net\<AppName>\<hash>\wwwroot) should contain MauiApp1.styles.css:

wwwroot/
├─ index.html
└─ MauiApp1.styles.css

So that Blazor scoped CSS is applied correctly at runtime.

##Actual Behavior##

The runtime extraction directory contains:
wwwroot/
├─ index.html
MauiApp1.styles.css is missing, even though it exists in the publish output.

##Request##

Please suggest a supported workaround or fix for the described issue.

If this is a bug, guidance on where it should be fixed would be appreciated. I would be happy to contribute, but would need direction on the appropriate place to start.

Is this a regression from previous behaviour?

  • This behaviour exists in .net 8.

Steps to Reproduce

  1. Create a .NET MAUI Blazor Hybrid App

  2. Add scoped CSS to any Razor component (e.g. MainLayout.razor.css)

  3. Publish using:

dotnet publish ^
  -f net8.0-windows10.0.19041.0 ^
  -r win-x64 ^
  -p:SelfContained=true ^
  -p:WindowsAppSDKSelfContained=true ^
  -p:PublishSingleFile=true ^
  -p:WindowsPackageType=None
  1. Observe publish output contains:

publish/
├─ MauiApp1.exe
└─ wwwroot/
---├─ index.html
---└─ MauiApp1.styles.css

  1. Run the published single-file EXE

Inspect runtime extraction directory:

%LOCALAPPDATA%\Temp\.net\<AppName>\<hash>\wwwroot and notice how it is missing MauiApp1.styles.css

Link to public reproduction project repository

https://github.com/Abdulrhman5/SingleFileMauiIssue

Version with bug

10.0.10

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

No response

Did you find any workaround?

Nope, I hope someone can suggest any.

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-blazorBlazor Hybrid / Desktop, BlazorWebViewplatform/windowss/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions