aspnetcore: net9 - Build a RCL fails if multiple files with same name but different extensions are under wwwroot
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
We have a RCL which produce multiple scripts, fonts, styles etc… under the wwwroot directory in order to ship them along the NuGet package and consume from aspnet blazor projects.
Each of these files have “gzip” and “brotli” compression version with the filename “[name].[ext].[compressionextension]”, so for example “interops.js” have “interops.js.gz” and “interops.js.br” files.
Until net8 it works good, but after update to net9 the build fails with and exception from StaticWebAssets.targets.
Deleting the “compressed version” ones the build completes.
Expected Behavior
We expect the same behavior of net8 build.
Steps To Reproduce
- Create a RCL;
- Create a wwwroot folder;
- Create script file named “test.js”:
- Create different extension-named version like “test.js.br” and “test.js.gz”:
- Try to build project:
Exceptions (if any)
Thrown from C:\Program Files\dotnet\sdk\9.0.100-rc.2.24474.11\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.targets(634,5):
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()
.NET Version
9.0.100-rc.2.24474.11
Anything else?
.NET SDK: Version: 9.0.100-rc.2.24474.11 Commit: 315e1305db Workload version: 9.0.100-manifests.3424025a MSBuild version: 17.12.0-preview-24473-03+fea15fbd1
Runtime Environment: OS Name: Windows OS Version: 10.0.22631 OS Platform: Windows RID: win-x64 Base Path: C:\Program Files\dotnet\sdk\9.0.100-rc.2.24474.11\
.NET workloads installed: [aspire] Installation Source: SDK 9.0.100-rc.2, VS 17.12.35424.110 Manifest Version: 8.2.2/8.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.2.2\WorkloadManifest.json Install Type: Msi
[wasm-tools] Installation Source: SDK 9.0.100-rc.2, VS 17.12.35424.110 Manifest Version: 9.0.0-rc.2.24473.5/9.0.100-rc.2 Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100-rc.2\microsoft.net.workload.mono.toolchain.current\9.0.0-rc.2.24473.5\WorkloadManifest.json Install Type: Msi
Configured to use loose manifests when installing new manifests.
Host: Version: 9.0.0-rc.2.24473.5 Architecture: x64 Commit: 990ebf52fc
.NET SDKs installed: 8.0.403 [C:\Program Files\dotnet\sdk] 9.0.100-rc.2.24474.11 [C:\Program Files\dotnet\sdk]
.NET runtimes installed: Microsoft.AspNetCore.App 8.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 9.0.0-rc.2.24474.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 8.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 9.0.0-rc.2.24473.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 8.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 9.0.0-rc.2.24474.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found: x86 [C:\Program Files (x86)\dotnet] registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables: Not set
global.json file: Not found
Learn more: https://aka.ms/dotnet/info
Download .NET: https://aka.ms/dotnet/download
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 7
- Comments: 29 (15 by maintainers)
Thanks for contacting us.
What’s likely happening here is that there is another compression system that is conflicting with the built-in compression support we’ve added. We have a separate issue to better detect external pre-compressed assets https://github.com/dotnet/aspnetcore/issues/57518 but there are two things you can do:
<CompressionEnabled>false</CompressionEnabled>in the csproj file to disable the built-in compression.If you still have issues after that, please let us know.
Same issue, working net8.0 project, upgraded to net9.0 just now and getting this too.
This is a shared feature between Blazor and MVC/Razor pages.
Turning the default compression off with
<CompressionEnabled>false</CompressionEnabled>in the relevant projects should be enough to unblock you, if that’s not the case, please file a separate issue and we’ll investigate.Sorry for replying again… You can detect files with identical names but different extensions with the following:
It will list duplicate files on top, replace
YourProjectwith the correct name 😉Sadly enough, even with no duplicates this fails for me
@Dona278 Sorry if it was not clear, I filed an issue to make sure that this gets documented on the appropriate places.
We have an old MVC app that has gone through .net core 1 -> 8 so far, nothing related to Blazor, and this has hit us.
The only compression I can find in our project is some
Microsoft.AspNetCore.ResponseCompression.We “solved” this by renaming
wwwroottowwwand changing the content folder. Far from a solution, but at least we are back in production now.I can’t understand how this one got through testing though… Our project is not so advanced to trigger these issues
@asabia we have the same configuration as you but the assets then will be pushed to cdn storage so our workaround was to exclude the scripts “as content” and include then in the nuget package through csproj. But then the issue moved to the project which has the reference to the library with another exception always related to a duplicated file under wwwroot directory…
I had the same issue. Disabling gzip in
bundlerconfig.jsonand removing*.*.gzipfiles in wwwroot, resolved it. { “outputFileName”: “wwwroot/css/app.css”, “inputFiles”: [ “Styles/app.css” ], “minify”: { “enabled”: true, “gzip”: false ← } },+1
Upgraded a
net8.0project that uses https://github.com/AnderssonPeter/CompressedStaticFiles tonet9.0and I’m getting this build error with dotnet sdk 9.0.100. I’ve made no code changes thus far; I am not using the new.MapStaticAssets()featureWorkaround was to rename the
wwwrootfolder to anything else and replaceapp.UseCompressedStaticFiles()withapp.UseCompressedStaticFiles(location: "<whatever_you_renamed_wwwroot_to>")