Skip to content

Version 2.0.38 - An item with the same key has already been added. #394

@ricaun

Description

@ricaun

Hello,

I was updating to use the version 2.0.38 and have the issue below.

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 System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at ILRepacking.Steps.ModuleInitializersRepackStep.TopologicalSort(HashSet`1 assemblies) in /_/ILRepack/Steps/ModuleInitializersRepackStep.cs:line 140
   at ILRepacking.Steps.ModuleInitializersRepackStep.RepackModuleInitializers() in /_/ILRepack/Steps/ModuleInitializersRepackStep.cs:line 52
   at ILRepacking.ILRepack.RepackCore(String tempOutputDirectory) in /_/ILRepack/ILRepack.cs:line 434
   at ILRepacking.ILRepack.Repack() in /_/ILRepack/ILRepack.cs:line 295
   at ILRepacking.Application.Main(String[] args) in /_/ILRepack/Application.cs:line 50

I basically repacking all the System.Text.Json references from version 9 inside a net8 dll.

I'm auto generating the command and the result looks like this:
ILRepack.exe /allowdup /allowduplicateresources /out:IssueILRepackOut.dll IssueILRepack.dll System.IO.Pipelines.dll System.Text.Encodings.Web.dll System.Text.Json.dll runtimes\browser\lib\net8.0\System.Text.Encodings.Web.dll

The main issue is related because System.Text.Encodings.Web.dll is added two times. If I use the 2.0.37 works fine, this means 2.0.38 have some bug.

This is my csproj to reproduce the issue using the command.

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="System.Text.Json" Version="*" />
  </ItemGroup>
</Project>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions