Maui Blazor Compilation error System.ArgumentException: An item with the same key has already been added.
- Dominant language
- C#
- Stars
- 23.3k
- Forks
- 2k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 290
Description
### Description
I am building a hybrid Blazor application, but I'm encountering an error during the build process when trying to launch the app.
I created a blazor project with the template:


In my solution, there is an additional project that contains the Pages. For this test I have created the MauiAppBlazor.Controls to simulate the scenary.

Finally I am getting this error in visual studio when I try to launch the app: System.ArgumentException: An item with the same key has already been added.
### Steps to Reproduce
1. Create a Maui Blazor App
2. Add a new project to put the MainPage
3. Move the wwwroot folder and components from the main maui project to the new project
4. From MauiAppBlazor reference the new project to call the MainPage
When you try to compile or launch the app, you will get this error:
2>C:\Program Files\dotnet\sdk\9.0.204\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.ScopedCss.targets(397,3): error MSB4018: The "FilterStaticWebAssetEndpoints" task failed unexpectedly.
2>C:\Program Files\dotnet\sdk\9.0.204\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.ScopedCss.targets(397,3): error MSB4018: System.ArgumentException: An item with the same key has already been added.
### Link to public reproduction project repository
https://github.com/jhovelnu/MauiAppBlazor
### Version with bug
9.0.70 SR7
### Is this a regression from previous behavior?
Not sure, did not test other versions
### Last version that worked well
_No response_
### Affected platforms
Android
### Affected platform versions
_No response_
### Did you find any workaround?
_No response_
### Relevant log output
```shell
```
Contributor guide
Research direction
Reproduce the failure with the linked MauiAppBlazor project, then inspect Microsoft.NET.Sdk.StaticWebAssets.targets around line 397 and the FilterStaticWebAssetEndpoints task. Done means the project compiles and launches without the duplicate-key ArgumentException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, csharp
- Domain
- build-system, mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100