Skip to content

Problem with duplicate Types #21

Open

Description

@THHoekstra

When using the TaskScheduler package (https://github.com/dahall/taskscheduler) in a project and using ILRepack to merge all assemblies, I get the following error:

error : Duplicate type System.Collections.Generic.EventedList`1 from GroupControls.dll, was also present in AeroWizard, Version=2.2.3.0, Culture=neutral, PublicKeyToken=915e74f5d64b8f37

Obviously, the same type is present in two repedent packages. How can I configure ILRepack to handle this problem?

Activity

  1. ravibpatel commented on Mar 5, 2020

    @ravibpatel
    Owner

    You can try providing ILRepack.targets similar to the following one in your projects folder.

    <!-- ILRepack -->
    <?xml version="1.0" encoding="utf-8" ?>
    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
        <Target Name="ILRepacker" AfterTargets="Build" Condition="'$(Configuration)' == 'Release'">
    
        <ItemGroup>
            <InputAssemblies Include="$(OutputPath)\ExampleAssemblyToMerge1.dll" />
            <InputAssemblies Include="$(OutputPath)\ExampleAssemblyToMerge2.dll" />
            <InputAssemblies Include="$(OutputPath)\ExampleAssemblyToMerge3.dll" />
        </ItemGroup>
    
        <ILRepack
            Parallel="true"
            Internalize="true"
            InputAssemblies="@(InputAssemblies)"
            TargetKind="Dll"
            OutputFile="$(OutputPath)\$(AssemblyName).dll"
            AllowedDuplicateNamespaces="System.Collections.Generic.*"
        />
    
        </Target>
    </Project>
    <!-- /ILRepack -->
  2. THHoekstra commented on Mar 5, 2020

    @THHoekstra
    Author

    Thank you for your answer.
    Does that mean I have to specify every assembly to include?
    I was hoping for an option similar to /allowDup in "ILMerge"

  3. ravibpatel commented on Mar 5, 2020

    @ravibpatel
    Owner

    Yes, You have to provide targets file to use AllowedDuplicateNamespaces option which should work similarly to /allowDup. You can use something like the following if you don't want to write every dll into the targets file.

    <!-- ILRepack -->
    <?xml version="1.0" encoding="utf-8" ?>
    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
        <Target Name="ILRepacker" AfterTargets="Build" Condition="'$(Configuration)' == 'Release'">
    
        <ItemGroup>
          <InputAssemblies Include="$(OutputPath)$(TargetName)$(TargetExt)"/>
          <InputAssemblies Include="$(OutputPath)*.dll" Exclude="$(OutputPath)$(TargetName)$(TargetExt)"/>
        </ItemGroup>
    
        <ILRepack
          Parallel="true"
          DebugInfo="true"
          AllowDuplicateResources="false"
          InputAssemblies="@(InputAssemblies)"
          TargetKind="SameAsPrimaryAssembly"
          AllowedDuplicateNamespaces="System.Collections.Generic.*"
          OutputFile="$(OutputPath)$(TargetName)$(TargetExt)"
        />
    
        </Target>
    </Project>
    <!-- /ILRepack -->
  4. THHoekstra commented on Mar 5, 2020

    @THHoekstra
    Author

    Thanks again. That looks good. I will try this.

  5. THHoekstra commented on Mar 5, 2020

    @THHoekstra
    Author

    My build fails without any Error Message in the output.
    How can I find out what's wrong with my targets file?

  6. ravibpatel commented on Mar 6, 2020

    @ravibpatel
    Owner

    Try providing a LogFile option. It should show up in the log.

  7. ravibpatel commented on Mar 6, 2020

    @ravibpatel
    Owner

    Or you can use MSBuild Log Viewer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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