Closed sk185828 closed 4 months ago
do you have a small example perhaps or a unit-test?
This is the code snippet which was written with ILMerge now I am trying to do the same with ILRepack . Here you will be able to see the method ILMerge.AllowDuplicateType
var mainAssemblyName = args[0].ToLower();
var assemblyBinFolder = args[1];
var finalBinFolder = args[2];
var specifiedVersion = "/v40";
var allowDup = false;
List<string> duplicateTypeList = null;
if (args.Length > 3)
{
if (args[3].ToLower().StartsWith("/v4"))
{
specifiedVersion = args[3];
}
var arg = args.Skip(3).FirstOrDefault(s => s.ToLower().StartsWith("/allowdup"));
if (arg != null)
{
allowDup = true;
var s = arg.Split(':');
if (s.Length > 1)
{
duplicateTypeList = s[1].Split(',').ToList();
}
}
}
ilmerge.FileAlignment = 512;
ilmerge.OutputFile = Path.Combine(finalBinFolder, mainAssemblyName);
ilmerge.SetInputAssemblies(properInputAssemblies);
if (allowDup)
{
if (duplicateTypeList == null)
{
ilmerge.AllowDuplicateType(null);
}
else
{
duplicateTypeList.ForEach(ilmerge.AllowDuplicateType);
}
}
ilmerge.Log = true;
ilmerge.Merge();
ILRepack already supports both the /allowdup
command-line arguments:
I just made AllowDuplicateType public: https://github.com/gluck/il-repack/commit/bc568451f0ca360ab7cea57caca4877db77e305f
I also made AllowAllDuplicateTypes settable: https://github.com/gluck/il-repack/commit/79d83e6a3ed3551f466aff69153061c0246afb75
But even today you can do this:
There was a method with ILMerge which used to take typeName in string format as a input to allow those type of assemblies to be duplicated . The syntax is given below
public void AllowDuplicateType(string typeName);