oqtane / oqtane.framework

CMS & Application Framework for Blazor & .NET MAUI
http://www.oqtane.org
MIT License
1.89k stars 547 forks source link

[BUG] Static Web Assets error on build #4834

Open mdmontesinos opened 1 week ago

mdmontesinos commented 1 week ago

Oqtane Info

Version - 6.0.0 Render Mode - Static Interactivity - Server Database - SQL Server

Describe the bug

Trying to build the Oqtane solution throws an error related to static web assets.

InvalidOperationException: Sequence contains more than one element
   at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)
   at Microsoft.AspNetCore.StaticWebAssets.Tasks.GenerateStaticWebAssetsDevelopmentManifest.<ComputeManifestAssets>d__19.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at Microsoft.AspNetCore.StaticWebAssets.Tasks.GenerateStaticWebAssetsDevelopmentManifest.ComputeDevelopmentManifest(IEnumerable`1 assets, IEnumerable`1 discoveryPatterns)
   at Microsoft.AspNetCore.StaticWebAssets.Tasks.GenerateStaticWebAssetsDevelopmentManifest.Execute()

This is already tracked in the ASP.NET Core repo, but I think it's best to also log it here so people with the error can find it easily.

https://github.com/dotnet/aspnetcore/issues/58859

It seems that the error happens when you have files with the same name but different extension in the wwwroot folder. As Oqtane uses this folder heavily to store most files, it's likely that you will encounter the error at some point. I can't pinpoint right now which files are triggering it, but the candidates could be minified files (X.css and X.min.css), compressed files (X.gz) or resized images (X.jpg and X.500x500.jpg)

EDIT: As mentioned in the original issue, deleting all compressed files (like bootstrap.min.css.gz) solves the issue. Minified files and resized images do not affect it.

Expected Behavior

Steps To Reproduce

Anything else?

sbwalker commented 1 week ago

I am trying to find an option for disabling the new Static Web Asset capability in .NET 9... but I have not had any luck yet. The "feature" does not work well for Oqtane... and slows down the build/publish process as it creates a .staticwebassets.endpoints.json file (which is 5 MB for Oqtane) and creates tons of .gz, *.br files... which results in a bloated deploy package.