Unable to build project using VS 18.2.1: “DiscoverPrecompressedAssets” task failed unexpectedly. An item with the same key has already been added
- Dominant language
- C#
- Stars
- 3.2k
- Forks
- 1.3k
- PR merge metrics
- PR metrics pending
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Describe the bug
This is probably the same bug as: https://github.com/dotnet/aspnetcore/issues/59625, which is closed. Or it could be part of this issue: https://github.com/dotnet/sdk/issues/50483, but it's slightly different. Here's another one: https://github.com/dotnet/sdk/issues/52089, and there was a debate where the bug should be discussed here: https://github.com/dotnet/aspnetcore/issues/64512, but no resolution that works for me even though it's closed.
My solution has five projects that I'm trying to upgrade from .Net 8 to .Net 10. The main project builds, but two dependent projects fail to build with the error “DiscoverPrecompressedAssets” task failed unexpectedly. An item with the same key has already been added.
I've tried:
- To delete the VS obj, bin and .vs folders before cleaning and rebuilding the solution/projects
- Moving all the Top-level packages from the sub-projects to Transitive except Microsoft.AspNetCore.App.Internal.Assets, which has a note that reads: "Implicitly referenced by an SDK. To update the package, update the SDK to which it belongs." (so it can't be moved)
- Cleaning/refreshing/updating/etc. the NuGet packages in the terminal (one error in the terminal pointed to blazor.web.js being duplicated, but I can't find where that might be)
- Removing any duplicate files under the wwwroot folder
- Adding a global.json file pointing to .Net 10
- NuGet Package Source Mapping
- Thought about migrating from packages.config to PackageReference, but decided it probably wouldn't help
- Investigating the project.assets.json file (https://christosmonogios.com/2024/12/07/how-to-deal-with-the-nuget-hell-of-transitive-dependencies-in-your-dot-net-projects/)
- The .NET Upgrade Assistant, which says there's an error but provides no usable guidance to correct it
- Probably something else I can't recall
Nothing works. Can Microsoft fix this or is there a work-around that works? Thanks!
### Expected Behavior
The projects should build. They're fine in .Net 8. The only thing that changed is migrating to .Net 10 and there does not appear to be any other underlying errors.
### Steps To Reproduce
Reproducing this issue is simple:
1) Create a new "Blazor Web App" (with or without authentication) using .Net 10 in Visual Studio 2026
2) Add another Blazor Web App to the solution
Both projects build and start fine, but
3) Add a Reference to the first project in the second project and the error above is generated and the second project won't build (the first one still builds)
### Exceptions (if any)
N/A
### .NET Version
10
### Anything else?
_No response_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.