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 17.12.3: “DiscoverPrecompressedAssets” task failed unexpectedly #59625
I've found a similar issue, but the exception there isn't the same (System.ArgumentException there and System.InvalidOperationException here) and that issue was closed without an answer, so I've decided to create a new one.
Basically, I'm unable to build an existing project that uses Blazor.BrowserExtension.Template. It used to work fine with version 17.11.35219.272.
Expected Behavior
Simply put, the project build should work without errors, as it used to do.
Here's the error I get whenever I try to build the project using VS 17.12.3:
The "DiscoverPrecompressedAssets" task failed unexpectedly.
System.InvalidOperationException: Fingerprint for '...\ExtensionTest\ExtensionTest\obj\Debug\net8.0\browserextension\build\BackgroundWorker.js' is not defined.
at Microsoft.AspNetCore.StaticWebAssets.Tasks.StaticWebAsset.Validate()
at Microsoft.AspNetCore.StaticWebAssets.Tasks.StaticWebAsset.FromTaskItem(ITaskItem item)
at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Microsoft.AspNetCore.StaticWebAssets.Tasks.DiscoverPrecompressedAssets.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
.NET Version
9.0.101
Anything else?
UPDATE: If I use SDK 8.0.404 and specify the version by adding a global.json to the solution folder, it actually works. Still no way to work with 9.0.101, though.
Hitting a similar error after upgrading from 8 to 9:
Error MSB4018 : The "DiscoverPrecompressedAssets" task failed unexpectedly.
System.ArgumentException: An item with the same key has already been added. Key: [path]\wwwroot\app.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)
As Github Copilot is being removed in 17.11, this is now beginning to be an issue as we cannot update without breaking our builds. The fix is in fact quite simple and already 2 PRs are open to fix it!
Hi, I'm hitting the same issue. VS Version 17.12.3. Project did not change for several months but suddenly it cannot be build.
The "DiscoverPrecompressedAssets" task failed unexpectedly. System.ArgumentException: An item with the same key has already been added. at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add)
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 comparer)
at Microsoft.AspNetCore.StaticWebAssets.Tasks.DiscoverPrecompressedAssets.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()`
We have also encountered this issue when attempting to update to .NET 9, based on Microsoft's recommendation that we do so in dotnet/maui#28475 to resolve the BlazorWebView component never being cleaned up when no longer needed in .NET 8.
I'm using Visual Studio 22 and Dotnet 7. I resolved this issue by switching from the current branch to the main branch and rebuilding the API. When I returned to my current branch, the build succeeded.
We believe these issues were addressed by #48952 and #49020 that are available in 9.0.301.
The issue was that a cache was not being correctly recomputed, and we were introducing duplicates into the cache that caused issues in later stages of the pipeline.
The original issue was addressed by deduplicating Content items before processing them as part of the pipeline.
If you still experience issues after upgrading to .NET SDK 9.0.302, please file a new issue to let us know.
Just encountered this problem when upgrading from .NET 9.0.307 SDK to .NET 10.0.100 under VS2022 Community (64-bit) Version 17.14.20, also removed all obj and bin and cleaned but it's still there,
That's interesting, I managed to build other solutions upgraded to .NET 10 on VS2022 17.14.20 without any problems. :)
That aside, I installed VS2026, and still have the same issue as I posted above, and like others here.
Also - just reopen this issue please as there seems to be no reason not to.
Reacted by Marlene Sætevik, Lucas Frendorf and TAL
Encountering this problem on VS2026 going from .Net 8 to .Net 10. Mine appears to be saying that blazor.web.js is the duplicate file, but I can't find where it's duplicated and none of the other fixes for the error work.
@LeeStevens318 thank you! Unfortunately, I had already checked this and in my case, the only shared package is: Microsoft.AspNetCore.App.Internal.Assets.
In my working .Net 8 version, I have 7 top-level packages shared by the project that won't build in .Net 10 (and over 271 that are Transitive). After upgrading to .Net 10, I have only one shared package (Microsoft.AspNetCore.App.Internal.Assets, which doesn't exist in my .Net 8 projects) and only 71 Transitive packages. The main project builds and runs, but this other project fails to build because of the "An item with the same key has already been added" error.
I can't remove Microsoft.AspNetCore.App.Internal.Assets (a note reads: "Implicitly referenced by an SDK. To update the package, update the SDK to which it belongs."). Any ideas?
Activity
MarcoMedrano commentedon Dec 24, 2024
I have the same issue building my maui app, your workaround is working (as I did not update my projects to dotnet 9):
global.json at root directory:
{ "sdk": { "version": "8.0.206" } }lofcz commentedon Jan 10, 2025
Hitting a similar error after upgrading from 8 to 9:
In csproj, I have several files linked as:
If I remove these links, the app builds but I can't use assets from the web project in the sln. This works as expected on 8.0.X
This is caused by:
https://github.com/dotnet/sdk/blob/1d3bf3b00bd92bc9eef62d56e97072425ea8d87f/src/StaticWebAssetsSdk/Tasks/Compression/DiscoverPrecompressedAssets.cs#L35C9-L35C106
ToDictionary()crashes if source contains duplicate keys.evgenyvalavin commentedon Jan 29, 2025
+1
TechnoZamb commentedon Feb 10, 2025
bump!!!
SirBirne commentedon Feb 11, 2025
This issue has persisted since SDK > 8.0.403 and I'm also looking forward to a fix.
Lionel-Renaux commentedon Feb 14, 2025
As Github Copilot is being removed in 17.11, this is now beginning to be an issue as we cannot update without breaking our builds. The fix is in fact quite simple and already 2 PRs are open to fix it!
LeeStevens318 commentedon Feb 17, 2025
bump
MiroslavJuhasCamea commentedon Feb 19, 2025
Hi, I'm hitting the same issue. VS Version 17.12.3. Project did not change for several months but suddenly it cannot be build.
The "DiscoverPrecompressedAssets" task failed unexpectedly. System.ArgumentException: An item with the same key has already been added. at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add)at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable
1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 comparer)at Microsoft.AspNetCore.StaticWebAssets.Tasks.DiscoverPrecompressedAssets.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()`
tbaggett-ebsco commentedon Mar 27, 2025
+1
We have also encountered this issue when attempting to update to .NET 9, based on Microsoft's recommendation that we do so in dotnet/maui#28475 to resolve the BlazorWebView component never being cleaned up when no longer needed in .NET 8.
35 remaining items
lbrpsoftware commentedon Jun 24, 2025
I'm on VS17.14.6 and dotnet 9.0.301 now.
The bug seems the have been resolved
Edit: VS17.4.7 🤗
aminmashayekhi commentedon Jun 24, 2025
Switch the calendar type to Georgian resolved the bug!
ruansilva123 commentedon Jul 24, 2025
I'm using Visual Studio 22 and Dotnet 7. I resolved this issue by switching from the current branch to the main branch and rebuilding the API. When I returned to my current branch, the build succeeded.
Maybe the problem was a build cache.🤔
javiercn commentedon Aug 2, 2025
We believe these issues were addressed by #48952 and #49020 that are available in 9.0.301.
The issue was that a cache was not being correctly recomputed, and we were introducing duplicates into the cache that caused issues in later stages of the pipeline.
The original issue was addressed by deduplicating Content items before processing them as part of the pipeline.
If you still experience issues after upgrading to .NET SDK 9.0.302, please file a new issue to let us know.
1944GPW commentedon Nov 12, 2025
Just encountered this problem when upgrading from .NET 9.0.307 SDK to .NET 10.0.100 under VS2022 Community (64-bit) Version 17.14.20, also removed all obj and bin and cleaned but it's still there,
danroth27 commentedon Nov 12, 2025
@1944GPW .NET 10 is only supported with VS 2026.
frazambi commentedon Nov 13, 2025
Still encountering this problem on both VS2026 and Rider 2025.3 on a .NET 10 project.
bwinklesky commentedon Nov 13, 2025
@frazambi I think they want a new issue to be submitted.
#59625 (comment)
1944GPW commentedon Nov 14, 2025
That's interesting, I managed to build other solutions upgraded to .NET 10 on VS2022 17.14.20 without any problems. :)
That aside, I installed VS2026, and still have the same issue as I posted above, and like others here.
Also - just reopen this issue please as there seems to be no reason not to.
tlevey01 commentedon Jan 19, 2026
Encountering this problem on VS2026 going from .Net 8 to .Net 10. Mine appears to be saying that blazor.web.js is the duplicate file, but I can't find where it's duplicated and none of the other fixes for the error work.
LeeStevens318 commentedon Jan 20, 2026
I was able to reproduce the error when a RCL and Web Project has the same package.
Here's example: https://github.com/LeeStevens318/csharp-discover-precompressed-assets
Which worked fine on .net 8, but caused an issue when upgrading to 9/10.
Microsoft Visual Studio Community
January 2026 Feature Update
Channel: Stable
Version: 18.2.0
tlevey01 commentedon Jan 21, 2026
@LeeStevens318 thank you! Unfortunately, I had already checked this and in my case, the only shared package is: Microsoft.AspNetCore.App.Internal.Assets.
In my working .Net 8 version, I have 7 top-level packages shared by the project that won't build in .Net 10 (and over 271 that are Transitive). After upgrading to .Net 10, I have only one shared package (Microsoft.AspNetCore.App.Internal.Assets, which doesn't exist in my .Net 8 projects) and only 71 Transitive packages. The main project builds and runs, but this other project fails to build because of the "An item with the same key has already been added" error.
I can't remove Microsoft.AspNetCore.App.Internal.Assets (a note reads: "Implicitly referenced by an SDK. To update the package, update the SDK to which it belongs."). Any ideas?
danroth27 commentedon Jan 22, 2026
@tlevey01 This issue is closed, so if you're still having this problem, please open a new one so that can triage it for investigation.