You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unable to build project using VS 18.2.1: “DiscoverPrecompressedAssets” task failed unexpectedly. An item with the same key has already been added #52647
This is probably the same bug as: dotnet/aspnetcore#59625, which is closed. Or it could be part of this issue: #50483, but it's slightly different. Here's another one: #52089, and there was a debate where the bug should be discussed here: dotnet/aspnetcore#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
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:
Create a new "Blazor Web App" (with or without authentication) using .Net 10 in Visual Studio 2026
Add another Blazor Web App to the solution
Both projects build and start fine, but
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)
Create a new "Blazor Web App" (with or without authentication) using .Net 10 in Visual Studio 2026
Add another Blazor Web App to the solution
Both projects build and start fine, but
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)
Seriously, is anyone at Microsoft trying to fix this?
In .Net 8 and 9, you get an error that the assets in the wwwroot folder are duplicated, but both projects build and run if you remove the duplicate files in one of the projects.
I have the same issue without Blazor, but with static websites.
>Microsoft.NET.Sdk.StaticWebAssets.Compression.targets(289,5): Error MSB4018 : The "DiscoverPrecompressedAssets" task failed unexpectedly.
System.ArgumentException: An item with the same key has already been added. Key: D:\Git\ToolsSite\wwwroot\css\announcement-generator.css
at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at System.Linq.Enumerable.SpanToDictionary[TSource,TKey](ReadOnlySpan`1 source, Func`2 keySelector, IEqualityComparer`1 comparer)
at System.Linq.Enumerable.ToDictionary[TSource,TKey](IEnumerable`1 source, Func`2 keySelector, IEqualityComparer`1 comparer)
at Microsoft.AspNetCore.StaticWebAssets.Tasks.DiscoverPrecompressedAssets.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(TaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)
0
Activity
tlevey01 commentedon Jan 24, 2026
Reproducing this issue is simple:
Both projects build and start fine, but
Seriously, is anyone at Microsoft trying to fix this?
In .Net 8 and 9, you get an error that the assets in the wwwroot folder are duplicated, but both projects build and run if you remove the duplicate files in one of the projects.
The problem file appears to be:
.nuget\packages\microsoft.aspnetcore.app.internal.assets\10.0.2_framework\blazor.web.js
dvdstelt commentedon Jan 27, 2026
I have the same issue without Blazor, but with static websites.
Handle duplicate static web asset identities gracefully