Reputation: 11914
Really struggling with an issue publishing a Blazor WASM project that is using .NET 6.
Previously, it was on .NET 5, and there were no issues with building / publishing the app.
I've updated it to .NET 6, by essentially updating the nuget references for:
Microsoft.AspNetCore.Components.WebAssembly
(to 6.0.0-rc.2.21480.10
)Microsoft.AspNetCore.Components.WebAssembly.DevServer
(to 6.0.0-rc.2.21480.10
)We've updated to .NET 6 due to a requirement on DynamicComponent
Running locally during development is fine.
During our build pipeline, I am executing the following to publish the app:
dotnet publish .\Web\Web.Connect --configuration debug --output output
The output that I am getting is:
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]
Ok - so some asset is trying to be published multiple times in ComputeBlazorPublishAssets
?
Found information indicating that adding <ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
to the *.csproj
might help here, but it has made no difference.
I have ensured that the wasm-tools
have been installed via dotnet workload install wasm-tools
.
Running a "Publish" via VS 2022 also gives the same error.
I am at a loss as to how I can debug this, or figure out what is getting generated twice, or how to fix this issue.
Thanks.
Upvotes: 2
Views: 1136
Reputation: 11914
Ok,
After a significant amount of investigation looking at the binlog files, I have managed to track this down to the fact that my referenced library (which is a netstandard 2.0
project shared with other projects in the solution) was also outputting an app.config
file (possibly due to an earlier time when we targeted both netstandard2.0
and net472
).
Looking at the MSBuild bin logs:
So, there were two compressed files with the same name - one was referencing the actual *.dll
, but the other was referencing *.dll.config
I deleted the app.config (it wasn't really needed and was probably there due to some historic reason) and it's now publishing as expected.
Upvotes: 1