Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with StaticWebAssets in Blazor WebAssembly Hosted on .NET 9.0 #59466

Open
Solbstr opened this issue Dec 13, 2024 · 7 comments
Open

Issue with StaticWebAssets in Blazor WebAssembly Hosted on .NET 9.0 #59466

Solbstr opened this issue Dec 13, 2024 · 7 comments
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug.
Milestone

Comments

@Solbstr
Copy link

Solbstr commented Dec 13, 2024

I encountered a significant issue while building my Blazor WebAssembly Hosted project after migrating to .NET 9.0.101. The build fails with over 200 errors related to missing .gz assets. These errors indicate that .gz files are being searched for in the compressed folder, even though these files were not added or generated during the build process.

The errors are triggered by Microsoft.NET.Sdk.StaticWebAssets.Compression.targets.

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label Dec 13, 2024
@javiercn
Copy link
Member

@Solbstr thanks for contacting us.

Do you have a repro you can share?

@javiercn javiercn added the Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. label Dec 13, 2024
@Solbstr
Copy link
Author

Solbstr commented Dec 13, 2024

Hi @javiercn,

I’ve been working on a fitness app for five years, and after migrating the project to .NET 9.0.101, I encountered build errors related to missing .gz assets. After extensive testing and troubleshooting, I discovered the root cause of the issue.

The problem was caused by the following line in the .csproj file of the Client project:

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
    <BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData>
    <BlazorWebAssemblyLoadGlobalizationDataForCultures>en-US;nb-NO</BlazorWebAssemblyLoadGlobalizationDataForCultures>
    <InvariantGlobalization>false</InvariantGlobalization>
    <CompressionEnabled>false</CompressionEnabled> <!-- This line caused the issue -->
    <BlazorEnableTimeZoneSupport>true</BlazorEnableTimeZoneSupport>
</PropertyGroup>

When I commented out or removed the CompressionEnabled property, the project built successfully. It seems this property, when explicitly set to false, causes .gz asset references to be handled incorrectly during the build process.

@dotnet-policy-service dotnet-policy-service bot added Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels Dec 13, 2024
@javiercn
Copy link
Member

@Solbstr thanks for the additional details.

That helps a lot, I'm able to reproduce it now.

@javiercn
Copy link
Member

It doesn't seem related to a fix that we took for servicing, but we are investigating, maybe something else has changed. From what I can see on the binlog, the asset does not contain the correct definition in this case.

The asset '\obj\Debug\net9.0\compressed\ni2t65rtxn-8fnvbemkr6.gz' can not be found at any of the searched locations '\bin\Debug\net9.0\wwwroot\_framework\System.Data.wasm' and '\bin\Debug\net9.0\wwwroot\_framework\System.Data.wasm'.

@javiercn
Copy link
Member

Ok, I figured it out.

Things go wrong in UpdateExternallyDefinedStaticWebAssets as it's changing the original item spec

Image

@javiercn
Copy link
Member

@javiercn
Copy link
Member

Just checked and it reproduces on 9.0 RTM, so it's a bug, but not a regression in any patch fix.

@javiercn javiercn added bug This issue describes a behavior which is not expected - a bug. and removed Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. labels Dec 13, 2024
@javiercn javiercn added this to the 9.0.x milestone Dec 13, 2024
@javiercn javiercn changed the title Issue with StaticWebAssets in Blazor WebAssembly Hosted on .NET 9.0.101 Issue with StaticWebAssets in Blazor WebAssembly Hosted on .NET 9.0 Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug.
Projects
None yet
Development

No branches or pull requests

2 participants