Search code examples
c#visual-studiomsbuildvisual-studio-2017

Visual Studio C# MSBuild.ILMerge.Task problem with The assembly is not marked as containing only managed code


I have Solution with 2 projects like:

  • MainDLL
  • LibraryDLL

I'd like to merge LibraryDLL inside MainDLL. My application require to import only one single file as plugin. I downloaded NUGet Packacged:

  • ILMerge
  • MSBuild.ILMerge.Task

After setting up, when I press build I am receiving following error:

ILMerge.Merge: The assembly 'ChilkatDotNet4' is not marked as containing only managed code.
(Consider using the /zeroPeKind option -- but read the documentation first!)

I am not using it directly and not need it but its proparbly refrenced by other referenced dll inside both projects (I dont need to include it because application already has it). How to avoid this problem? I have tried to setup flag:

<!-- See ILMerge documentation -->
<ILMergeAllowZeroPeKind></ILMergeAllowZeroPeKind>

To true or false but nothing changes


Solution

  • Working with /zeroPeKind was unsuccessful for me (doesn't mean its wrong way). I can't also rebuild this native c++ library, because it comes from external provider.

    After checking https://github.com/emerbrito/ILMerge-MSBuild-Task/wiki

    Merge Assemblies With Copy Local = True

    I have changed all other References property setting Copy Local to false.

    I left Copy Local = true only for referenced my shared project library which I wanted to merge with my main project.