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
-
Create a .NET MAUI Blazor Hybrid App
-
Add scoped CSS to any Razor component (e.g. MainLayout.razor.css)
-
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
- Observe publish output contains:
publish/
├─ MauiApp1.exe
└─ wwwroot/
---├─ index.html
---└─ MauiApp1.styles.css
- 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
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:
##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?
Steps to Reproduce
Create a .NET MAUI Blazor Hybrid App
Add scoped CSS to any Razor component (e.g. MainLayout.razor.css)
Publish using:
publish/
├─ MauiApp1.exe
└─ wwwroot/
---├─ index.html
---└─ MauiApp1.styles.css
Inspect runtime extraction directory:
%LOCALAPPDATA%\Temp\.net\<AppName>\<hash>\wwwrootand notice how it is missing MauiApp1.styles.cssLink 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