Error in publishing solution to a folder - Self hosted .NET

Viewed 246

I have an app/solution with multiple projects inside (.NET 6 - self-hosted Blazor WASM) It can build and run in debugging without any issues.

Now, i tried to publish it for testing in some of our local servers, and i try to publish it to a folder, and run as an .exe.

Problem is, when i try to publish it, somewhere after building succesfully, i receive the following error :

Optimizing assemblies for size, which may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
Optimizing assemblies for size, which may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
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.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at Microsoft.NET.Sdk.BlazorWebAssembly.ComputeBlazorPublishAssets.GroupExistingStaticWebAssets(Dictionary`2 assemblyAssets, Dictionary`2 nativeAssets, Dictionary`2 satelliteAssemblyAssets, Dictionary`2 symbolAssets, Dictionary`2 compressedRepresentations)
   at Microsoft.NET.Sdk.BlazorWebAssembly.ComputeBlazorPublishAssets.Execute()

Any ideas what could cause this ? I am using VS 2022 (Enterprise).

1 Answers

This error seems a lot like an open issue #37610 - Blazor AOT compilation fails at ComputeBlazorPublishAssets.GroupExistingStaticWebAssets

Here are the steps to further diagnose the problem:

You can capture a binary log with dotnet publish /bl and use MSBuild structured log viewer to look at the ComputeBlazorPublishAssets task. Within there, if you expand the parameters, it'll show all the ExistingAssets and you can get a better idea of what's happening. (You'll see the duplicated asset)

You can download MSBuild structured log viewer from here: https://msbuildlog.com/

Related