Search code examples
.net-coreblazordotnet-sdk.net-9.0

DefineStaticWebAssetEndpoints erro in .NET 9 Blazor


I recently updated the .NET version and the VS version to 9.0 and I'm getting this error:

The "DefineStaticWebAssetEndpoints" 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.DefineStaticWebAssetEndpoints.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__26. MoveNext()

I tried these steps:

  1. Looked for multiple entries that refer to the same file in .csproj
  2. Clean the build, cache and ran the project again.
  3. Restarted Visual Studio

I am new to .NET and looking for an answer for this issue.


Solution

  • There is update recently. This issue exist in .NET9.0.100-preview.7. But a release candidate verison .NET9.0.100-rc.1 has just release at Sep 10th. You could try the latest version and this issue has disappeared. enter image description here

    The build result : enter image description here