我正在使用ILMerge版本2.11.1103.0将4个DLL合并到一个新程序集中。假设它们被称为A,B,C和D,它们的关系如下:
B -> A
C -> A
D -> A
D -> C
当我在A,B和C上运行ILMerge时,一切都运行得很好。但是当我添加D时,我收到以下错误:
An exception occurred during merging:
ILMerge.Merge: The assembly 'A' was not merged in correctly.
It is still listed as an external reference in the target assembly.
at ILMerging.ILMerge.Merge()
at ILMerging.ILMerge.Main(String[] args)
我尝试使用ILMerge DLL: Assembly not merged in correctly, still listed as an external reference所示的/ closed选项,但遗憾的是它无效:
In order to close the target assembly, the number of assemblies to be added to the input is 0.
当我更改程序集的顺序时,我收到以下异常:
An exception occurred during merging:
Index was outside the bounds of the array.
at System.Compiler.ISymUnmanagedWriter.CloseMethod()
at System.Compiler.Ir2md.VisitMethodBody(Method method)
at System.Compiler.Ir2md.VisitMethod(Method method)
at System.Compiler.Ir2md.Visit(Node node)
at System.Compiler.Ir2md.VisitClass(Class Class)
at System.Compiler.Ir2md.Visit(Node node)
at System.Compiler.Ir2md.VisitModule(Module module)
at System.Compiler.Ir2md.SetupMetadataWriter(String debugSymbolsLocation)
at System.Compiler.Ir2md.WritePE(Module module, String debugSymbolsLocation, BinaryWriter writer)
at System.Compiler.Writer.WritePE(String location, Boolean writeDebugSymbols, Module module, Boolean delaySign, String keyFileName, String keyName)
at System.Compiler.Writer.WritePE(CompilerParameters compilerParameters, Module module)
at System.Compiler.Module.WriteModule(String location, CompilerParameters options)
at ILMerging.ILMerge.Merge()
at ILMerging.ILMerge.Main(String[] args)
我正在使用的完整命令行是:
ILMerge.exe /targetplatform:v4,"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0" /log:ilmerge.log /target:library /union /xmldocs /copyattrs /allowMultiple /internalize /closed /keyfile:keyfile.snk /out:Merged.dll A B C D
谁能看到我做错了什么?感谢。
答案 0 :(得分:4)
正如@HansPassant在上述评论中所建议的那样,我联系了微软成名的Mike Barnett。他能够帮我解决这个问题:
从http://nuget.org/packages/ilmerge升级到最新版本的ilmerge(2.12.0803)
从命令中删除/ union开关(这是之前添加的,用于解决在代码合同重写器重写的合并程序集上运行gendarme的问题。幸运的是,由于构建过程中的更改,这是否定的需要更长时间)。
答案 1 :(得分:1)
我遇到过ILMerge以前无法正常工作的问题。我想他们只是错误...尝试合并多个阶段,例如将B和A合并到A',然后将A'与C和D合并。这可能会产生不同的结果/错误,从而导致解决方案。