【发布时间】:2021-11-02 23:01:36
【问题描述】:
在发布使用 .NET 6 的 Blazor WASM 项目时遇到了问题。
以前,它在 .NET 5 上,构建/发布应用程序没有问题。
我已将其更新为 .NET 6,主要是更新以下 nuget 引用:
-
Microsoft.AspNetCore.Components.WebAssembly(转至6.0.0-rc.2.21480.10) -
Microsoft.AspNetCore.Components.WebAssembly.DevServer(转至6.0.0-rc.2.21480.10)
由于DynamicComponent 的要求,我们已更新到 .NET 6
在开发过程中本地运行没问题。
在我们的构建管道期间,我正在执行以下操作来发布应用程序:
dotnet publish .\Web\Web.Connect --configuration debug --output output
我得到的输出是:
Web.Connect -> C:\git\core\Web\Web.Connect\bin\debug\net6.0\Web.Connect.dll
Web.Connect (Blazor output) -> C:\git\core\Web\Web.Connect\bin\debug\net6.0\wwwroot
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-rc.2.21505.57\Sdks\Microsoft.NET.Sdk.BlazorWebAssembly\targets\Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets(404,5): error : System.ArgumentException: An item with the same key has already been added. Key: C:\git\core\Web\Web.Connect\obj\debug\net6.0\build-gz\bxkpRzBw.gz [C:\git\core\Web\Web.Connect\Web.Connect.csproj]
C:\Program Files\dotnet\sdk\6.0.100-rc.2.21505.57\Sdks\Microsoft.NET.Sdk.BlazorWebAssembly\targets\Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets(404,5): error : at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) [C:\git\core\Web\Web.Connect\Web.Connect.csproj]
C:\Program Files\dotnet\sdk\6.0.100-rc.2.21505.57\Sdks\Microsoft.NET.Sdk.BlazorWebAssembly\targets\Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets(404,5): error : at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value) [C:\git\core\Web\Web.Connect\Web.Connect.csproj]
C:\Program Files\dotnet\sdk\6.0.100-rc.2.21505.57\Sdks\Microsoft.NET.Sdk.BlazorWebAssembly\targets\Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets(404,5): error : at Microsoft.NET.Sdk.BlazorWebAssembly.ComputeBlazorPublishAssets.GroupExistingStaticWebAssets(Dictionary`2 assemblyAssets, Dictionary`2 nativeAssets, Dictionary`2 satelliteAssemblyAssets, Dictionary`2 symbolAssets, Dictionary`2 compressedRepresentations) [C:\git\core\Web\Web.Connect\Web.Connect.csproj]
C:\Program Files\dotnet\sdk\6.0.100-rc.2.21505.57\Sdks\Microsoft.NET.Sdk.BlazorWebAssembly\targets\Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets(404,5): error : at Microsoft.NET.Sdk.BlazorWebAssembly.ComputeBlazorPublishAssets.Execute() [C:\git\core\Web\Web.Connect\Web.Connect.csproj]
好的 - 所以某些资产正试图在 ComputeBlazorPublishAssets 中多次发布?
发现信息表明将<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles> 添加到*.csproj 可能会有所帮助,但没有任何区别。
我已确保wasm-tools 已通过dotnet workload install wasm-tools 安装。
通过 VS 2022 运行“发布”也会出现同样的错误。
我不知道如何调试它,或者弄清楚生成了两次的内容,或者如何解决这个问题。
谢谢。
【问题讨论】:
标签: c# blazor-webassembly .net-6.0