[BUG] Static Web Assets error on build
Closed this issue · 3 comments
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.
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?
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.
Hi @mdmontesinos , could you please provide the detail steps to reproduce this issue? I tried to build the solution both in Debug and Release mode but didn't see any error.
Hi @zyhfish, as mentioned in my original comment and the dotnet issue, this error only happens if you have already compressed assets that are trying to be compressed as well by the new static assets compression and manifest.
I just posted the issue here as well to help other users that might encounter it. A workaround/solution was already discussed in the dotnet repo, so you can close this is you want.