aspnetcore: Visual Studio 2022 Blazor project builds and runs successfully but publish fails with System.ArgumentException

This issue has been moved from a ticket on Developer Community.


Visual Studio 2022 Blazor project builds and runs successfully but publish fails with the following error

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 Microsoft.NET.Sdk.BlazorWebAssembly.ComputeBlazorPublishAssets.GroupExistingStaticWebAssets(Dictionary2 assemblyAssets, Dictionary2 nativeAssets, Dictionary2 satelliteAssemblyAssets, Dictionary2 symbolAssets, Dictionary2 compressedRepresentations) at Microsoft.NET.Sdk.BlazorWebAssembly.ComputeBlazorPublishAssets.Execute() Client 0

The attached solution (bug.7z) contains the necessary solution and project files to reproduce the error. Just unzip and set Client as the startup project. It should build and run successfully but when you try and publish the Client project it will give the error. If this turns out not to be a Visual Studio error, please improve the error message in order to make the debug process easier.


Original Comments

Feedback Bot on 11/7/2021, 07:43 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.


Original Solutions

(no solutions)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (10 by maintainers)

Most upvoted comments

I am getting same error during publish process, but I really dont undersand how to find where the problem is

C:\Program Files\dotnet\sdk\6.0.100\Sdks\Microsoft.NET.Sdk.BlazorWebAssembly\targets\Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets(412,5): Error : 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 Microsoft.NET.Sdk.BlazorWebAssembly.ComputeBlazorPublishAssets.GroupExistingStaticWebAssets(Dictionary2 assemblyAssets, Dictionary2 nativeAssets, Dictionary2 satelliteAssemblyAssets, Dictionary2 symbolAssets, Dictionary2 compressedRepresentations) at Microsoft.NET.Sdk.BlazorWebAssembly.ComputeBlazorPublishAssets.Execute()