Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with duplicate Types #21

Open
THHoekstra opened this issue Mar 5, 2020 · 7 comments
Open

Problem with duplicate Types #21

THHoekstra opened this issue Mar 5, 2020 · 7 comments

Comments

@THHoekstra
Copy link

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?

@ravibpatel
Copy link
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 -->

@THHoekstra
Copy link
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"

@ravibpatel
Copy link
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 -->

@THHoekstra
Copy link
Author

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

@THHoekstra
Copy link
Author

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

@ravibpatel
Copy link
Owner

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

@ravibpatel
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants