Skip to content

.net 8 publish failed with error "An item with the same key has already been added" #89234

@jjzhang12

Description

@jjzhang12

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Migrated our .net 7 Blazor application to .net 8 preview 6, visual studio 2023 17.7 preview 4. I can compile and run the project. But when I publish, I got the error

"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.browser-wasm\8.0.0-preview.6.23329.7\Sdk\..\tools\mono-aot-cross.exe" --print-icall-table > "C:\omi.web\Source\Web\Core\Viewer\obj\Release\wasm\for-publish\runtime-icall-table.h"
emcc --version
Compiling native assets with emcc with -Oz. This may take a while ...
C:\Users\JJ Zhang\.nuget\packages\microsoft.net.sdk.webassembly.pack\8.0.0-preview.6.23329.7\build\Microsoft.NET.Sdk.WebAssembly.Browser.targets(379,5): Error : System.ArgumentException: An item with the same key has already been added.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at Microsoft.NET.Sdk.WebAssembly.ComputeWasmPublishAssets.GroupExistingStaticWebAssets(Dictionary`2 assemblyAssets, Dictionary`2 nativeAssets, Dictionary`2 satelliteAssemblyAssets, Dictionary`2 symbolAssets, Dictionary`2 compressedRepresentations)
   at Microsoft.NET.Sdk.WebAssembly.ComputeWasmPublishAssets.Execute()

1>Build failed. Check the Output window for more details.

And here is the log file referred in the pop message:

7/19/2023 12:16:31 PM
System.AggregateException: One or more errors occurred. ---> Microsoft.WebTools.Shared.Exceptions.WebToolsException: Build failed. Check the Output window for more details.
   --- End of inner exception stack trace ---
---> (Inner Exception #0) Microsoft.WebTools.Shared.Exceptions.WebToolsException: Build failed. Check the Output window for more details.<---

Microsoft.WebTools.Shared.Exceptions.WebToolsException: Build failed. Check the Output window for more details.

Expected Behavior

The publish shall succeed.
At least the error message shall tell which item has already been added.

Steps To Reproduce

Not see in a simple application, but with our full application.

At least should show some clue how to identify the issue.

Exceptions (if any)

System.ArgumentException: An item with the same key has already been added.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at Microsoft.NET.Sdk.WebAssembly.ComputeWasmPublishAssets.GroupExistingStaticWebAssets(Dictionary`2 assemblyAssets, Dictionary`2 nativeAssets, Dictionary`2 satelliteAssemblyAssets, Dictionary`2 symbolAssets, Dictionary`2 compressedRepresentations)
   at Microsoft.NET.Sdk.WebAssembly.ComputeWasmPublishAssets.Execute()

.NET Version

8.0.100-preview.6.23330.14

Anything else?

No response

Metadata

Metadata

Assignees

Labels

arch-wasmWebAssembly architecturearea-VM-meta-mononeeds-further-triageIssue has been initially triaged, but needs deeper consideration or reconsideration

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions