Skip to content
Denis Kuzmin [ GitHub/3F ] edited this page Jun 12, 2020 · 2 revisions

Pre-processing

Some manipulation for modules together with .NET DllExport tool is not a rare question as we can see. [?]

Predefined features

Conari support

Easiest access to unmanaged things through integration with Conari in "one click".

There are no more any possible problems with loading the assembly and resolving its types: https://github.com/3F/Conari/issues/11#issuecomment-625436847

ILMerge support

Official ILMerge support:

Manual configuring (msbuild)

Example: https://github.com/3F/DllExport/issues/40#issuecomment-593147220

<!-- https://ko-fi.com/post/ILMerge-and-other-related-3rd-party-tool-for--NET-Y8Y71FVU4 -->

...
  <!-- For .NET DllExport 1.7 -->

  <Target Name="Merging" BeforeTargets="DllExportMod">
    <Copy SourceFiles="$(DllExportMetaLibFullPath)" 
          DestinationFolder="$(TargetDir)" 
          SkipUnchangedFiles="true" 
          OverwriteReadOnlyFiles="true" />

    <Exec Command="$(ILMergeConsolePath) Conari.dll $(TargetFileName) /out:$(TargetFileName) /ndebug"
          WorkingDirectory="$(TargetDir)"
          ContinueOnError="true" />
    
    <Delete Files="$(TargetDir)$(DllExportMetaLibName)" ContinueOnError="true" />  
  </Target>

  <ItemGroup>
    <PackageReference Include="Conari" Version="1.4.0" />
    <PackageReference Include="ilmerge" Version="3.0.29" />
  </ItemGroup>  
...

Alternative to AssemblyResolve

As you should already know, an AssemblyResolve is one of the possible solutions for the problems with types when you observe FileNotFoundException and related, for example:

Pre-processing with ILMerge is another way to achieve the same result without additional programming at all.

Same for Conari