dotnet / ILMerge

ILMerge is a static linker for .NET Assemblies.
MIT License
1.23k stars 170 forks source link

Is it possible to use ILMerge with Structuremap or other typescanning utility? #45

Open lilasquared opened 6 years ago

lilasquared commented 6 years ago

I am trying to create a portable console application that has no dependent dlls, so I found ILMerge which does the trick. However when trying to incorporate structuremap the scanning functionality of the registry does not seem to be working. Exception below.

An unhandled exception of type 'System.TypeLoadException' occurred in mscorlib.dll

Additional information: Could not load type '<MediatR-IRequestHandler<TRequest\,MediatR-Unit>-Handle>d__0' from assembly 'queue, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' because the parent does not exist.

I am using a another nuget package called MediatR which exposes some types that I would assume should now be bundled into my assembly.

Just curious if this is supported and I am doing something wrong or if ILMerge does not support this. Thanks!

The structuremap registry is simple:

Scan(x =>
{
    x.AssembliesAndExecutablesFromApplicationBaseDirectory();

    x.ConnectImplementationsToTypesClosing(typeof(IRequestHandler<,>));
});