I am doing a proof of concept to understand how ILRepack (ILRepack.MSBuild.Task) works.
With this configuration, I am able to create a single merged dll, with ClassLibrary1, AutoMapper and Newtonsoft.Json internalized correctly:
<Target Name="AfterBuild" Condition="'$(Configuration)' == 'Release'">
<ItemGroup>
<InputAssemblies Include="$(OutputPath)\ClassLibrary2.dll" />
<InputAssemblies Include="$(OutputPath)\ClassLibrary1.dll" />
<InputAssemblies Include="$(OutputPath)\AutoMapper.dll" />
<InputAssemblies Include="$(OutputPath)\Newtonsoft.Json.dll" />
</ItemGroup>
<ItemGroup>
<!-- Must be a fully qualified name -->
<DoNotInternalizeAssemblies Include="ClassLibrary2" />
</ItemGroup>
<ILRepack Parallel="true" Internalize="true" InternalizeExclude="@(DoNotInternalizeAssemblies)" InputAssemblies="@(InputAssemblies)" TargetKind="Dll" OutputFile="$(OutputPath)\$(AssemblyName).dll" />
However, when I am trying to use wildcards, internalize don't works:
<Target Name="AfterBuild" Condition="'$(Configuration)' == 'Release'">
<ItemGroup>
<InputAssemblies Include="$(OutputPath)\*.dll" />
</ItemGroup>
<ItemGroup>
<!-- Must be a fully qualified name -->
<DoNotInternalizeAssemblies Include="ClassLibrary2" />
</ItemGroup>
<ILRepack Parallel="true" Internalize="true" InternalizeExclude="@(DoNotInternalizeAssemblies)" InputAssemblies="@(InputAssemblies)" TargetKind="Dll" OutputFile="$(OutputPath)\$(AssemblyName).dll" />
Any idea why this is happening?
EDIT: Looks like the wildcards reorders the assemblies. Automapper is not internalized (because become the primary assembly), but all the others are (except ClassLibrary2, I suppose the DoNotInternalizeAssemblies does it's job)