I have main assembly MyAssembly.dll
and a lot of libraries which I want to merge into main assembly. Because there are lots of them, I wanted to include them all using wildcard, something like this:
ILMerge.exe /wildcard /allowDup /out:MyAssembly.Merged.dll MyAssembly.dll *.dll
The problem with this approach is that it merges MyAssembly.dll
twice, resulting in duplicated type names, so need to use /allowDup
option. But this option renames duplicated types, and I don't want that (my DLL is a plugin for other application and all types must have original names).
I could omit MyAssembly.dll
in command line, but because ILMerge merges assemblies alphabetically, it treats the first one as a main assembly (for example Autofac.dll
) which results in final assembly having wrong metadata (version etc.).
Is it possible to exclude certain assembly name with wildcard option?
Is it possible to exclude certain assembly name with wildcard option?
No. You could write a batch file that builds the command line though, using for
for example. You could also write a script in another language.
However ilmerge
is an artefact of the past and it has a whole slew of problems. Since it copies the code into one assembly it changes how run-time loading works, which can easily break lazy-loaded programs like WPF or ASP.NET Core.
Nowadays we have .Net5 which provides first-class support for single-assembly binaries, both that run under the installed environment (like your assembly used to need) or self-contained (it includes the .net5 runtime as well). It doesn't mash together the code into one assembly, it sticks to separate assemblies loaded at run-time directly from your generated large "assembly", so your actual code doesn't change.