我有一个应用程序/解决方案,里面有多个项目(.NET 6-自托管Blazor WASM(它可以在调试中构建和运行,而不会出现任何问题。
现在,我尝试将它发布到我们的一些本地服务器中进行测试,并尝试将其发布到一个文件夹中,并以.exe.的形式运行
问题是,当我试图在成功构建后的某个地方发布它时,我收到了以下错误:
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 Filesdotnetsdk6.0.100SdksMicrosoft.NET.Sdk.BlazorWebAssemblytargetsMicrosoft.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()
你知道是什么原因造成的吗?我正在使用VS 2022(企业版(。
此错误看起来很像一个悬而未决的问题#37610-ComputeBlazorPublishAssets.GroupExistingStaticWebAssets 上的Blazor AOT编译失败
以下是进一步诊断问题的步骤:
您可以使用
dotnet publish /bl
捕获二进制日志,并使用MSBuild结构化日志查看器查看ComputeBlazorPublishAssets任务。在那里,如果你展开参数,它会显示所有的ExistingAssets,你可以更好地了解发生了什么。(您将看到重复的资产(
您可以从这里下载MSBuild结构化日志查看器:https://msbuildlog.com/