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

net9 - Build a RCL fails if multiple files with same name but different extensions are under wwwroot #58859

Open
1 task done
Dona278 opened this issue Nov 10, 2024 · 14 comments
Labels
area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework

Comments

@Dona278
Copy link
Contributor

Dona278 commented Nov 10, 2024

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

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework label Nov 10, 2024
@JarleSkahjem
Copy link

Can confirm that I have the same issue, tested with released .net9.

@judilsteve
Copy link

judilsteve commented Nov 13, 2024

+1

Upgraded a net8.0 project that uses https://github.com/AnderssonPeter/CompressedStaticFiles to net9.0 and 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() feature

Workaround was to rename the wwwroot folder to anything else and replace app.UseCompressedStaticFiles() with app.UseCompressedStaticFiles(location: "<whatever_you_renamed_wwwroot_to>")

@CumpsD
Copy link
Contributor

CumpsD commented Nov 13, 2024

Same issue, working net8.0 project, upgraded to net9.0 just now and getting this too.

/usr/share/dotnet/sdk/9.0.100/Sdks/Microsoft.NET.Sdk.StaticWebAssets/targets/Microsoft.NET.Sdk.StaticWebAssets.targets(634,5):
error : InvalidOperationException: Sequence contains more than one element [/Website/Website.csproj]
....
/usr/share/dotnet/sdk/9.0.100/Sdks/Microsoft.NET.Sdk.StaticWebAssets/targets/Microsoft.NET.Sdk.StaticWebAssets.targets(634,5):
error :    at Microsoft.AspNetCore.StaticWebAssets.Tasks.GenerateStaticWebAssetsDevelopmentManifest.Execute() 

@MauricioRodolfo
Copy link

+1

@asillye
Copy link

asillye commented Nov 14, 2024

same here

@asabla
Copy link

asabla commented Nov 14, 2024

Haven't had the opportunity to debug this my self yet. But it seems like this is were things explode https://github.com/dotnet/sdk/blob/2d87cb8327aa0d998bc5a5e34cbcf6585c8dc5af/src/StaticWebAssetsSdk/Tasks/GenerateStaticWebAssetsDevelopmentManifest.cs#L66

For history:

var assetsWithPathSegments = ComputeManifestAssets(assets).ToArray();

We're experiencing the same issue, when we include the output from a webpack build in our wwwroot directory for a blazor wasm project. We're not using either MapStaticAssets() nor UseCompressedStaticFiles(). Are there any viable workarounds? Would it be preferred to publish files (from webpack) as non optimized and let the build task do it's thing instead?

@rmin001
Copy link

rmin001 commented Nov 14, 2024

I had the same issue. Disabling gzip in bundlerconfig.json and removing *.*.gzip files in wwwroot, resolved it.
{
"outputFileName": "wwwroot/css/app.css",
"inputFiles": [
"Styles/app.css"
],
"minify": {
"enabled": true,
"gzip": false ←
}
},

@Dona278
Copy link
Contributor Author

Dona278 commented Nov 14, 2024

@rmin001 I confirm that only gzipped files cause the problem.. if I disable gzip and keep only brotli compression through webpack the build works

@Dona278
Copy link
Contributor Author

Dona278 commented Nov 14, 2024

@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..

@VendorAttestation
Copy link

Having same issue disabling GZip isn't a option guess ill wait to come from NET 8

@mdmontesinos
Copy link

I'm also experiencing this error. This makes it impossible for most apps to migrate to .NET 9. Even having both the regular and minified version of a static asset (like css or js) seems to trigger the error. We need a fix or workaround.

@CumpsD
Copy link
Contributor

CumpsD commented Nov 15, 2024

Haven't had the opportunity to debug this my self yet. But it seems like this is were things explode dotnet/sdk@2d87cb8/src/StaticWebAssetsSdk/Tasks/GenerateStaticWebAssetsDevelopmentManifest.cs#L66

For history:

var assetsWithPathSegments = ComputeManifestAssets(assets).ToArray();

We're experiencing the same issue, when we include the output from a webpack build in our wwwroot directory for a blazor wasm project. We're not using either MapStaticAssets() nor UseCompressedStaticFiles(). Are there any viable workarounds? Would it be preferred to publish files (from webpack) as non optimized and let the build task do it's thing instead?

Seems to explode a step deeper on the Single:
https://github.com/dotnet/sdk/blob/262b9c3d6cf67287f649e38d83e6c5d9d08feb8a/src/StaticWebAssetsSdk/Tasks/GenerateStaticWebAssetsDevelopmentManifest.cs#L105

@CumpsD
Copy link
Contributor

CumpsD commented Nov 15, 2024

@CumpsD
Copy link
Contributor

CumpsD commented Nov 15, 2024

Sorry for replying again... You can detect files with identical names but different extensions with the following:

grep -oP "(?<=<RelativePath>).*(?=</RelativePath>)" YourProject/obj/Release/net9.0/staticwebassets/msbuild.YourProject.Microsoft.AspNetCore.StaticWebAssets.props | sed 's/\.[^.]*$//'  | sort | uniq -c | less

It will list duplicate files on top, replace YourProject with the correct name ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework
Projects
None yet
Development

No branches or pull requests

10 participants