ILMerge icon indicating copy to clipboard operation
ILMerge copied to clipboard

Unresolved assembly reference not allowed: `System.Drawing.Common`

Open Logerfo opened this issue 5 years ago • 6 comments

I'm trying to merge a .NET Core 3.0 Windows Forms app.

An exception occurred during merging: Unresolved assembly reference not allowed: System.Drawing.Common. at System.Compiler.Ir2md.GetAssemblyRefIndex(AssemblyNode assembly) at System.Compiler.Ir2md.GetTypeRefIndex(TypeNode type) at System.Compiler.Ir2md.VisitReferencedType(TypeNode type) 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)

Logerfo avatar Sep 30 '19 17:09 Logerfo

You need to provide the paths to all of the input (directly or indirectly referenced) assemblies. Please see Section 2.20 in the manual. If that doesn't fix it, then please repost your problem.

mike-barnett avatar Sep 30 '19 17:09 mike-barnett

Alright, I did that, then I got the same error for another dependency. I supposed I must do all that for every single one of them, but it seems unpractical to me:

$(ILMergeConsolePath) /ndebug /lib:$(NuGetPackageRoot)/system.drawing.common/4.5.1/runtimes/win/lib/netcoreapp2.0 /out:...

Isn't there a recursive search path or something like that?

Logerfo avatar Sep 30 '19 17:09 Logerfo

Hmm, a recursive search path would probably have been a good idea! But you probably can just use the output directory of the projects that you are merging. I would think the nuget packages would all have resulted in the assemblies being copied to the output directory. Or is that not the case?

mike-barnett avatar Sep 30 '19 17:09 mike-barnett

You're right, that's the case. It's better, but recursive would be best.

Logerfo avatar Sep 30 '19 17:09 Logerfo

Possibly: it is also likely that an overly broad search could find lots of competing versions of the same assembly and it would be difficult to know which one is the right one unless you load all of them.

mike-barnett avatar Sep 30 '19 18:09 mike-barnett

I would think the nuget packages would all have resulted in the assemblies being copied to the output directory.

Not everything, tho. NETCore.App and NETCore.WindowsDesktop stuff doesn't.

Logerfo avatar Sep 30 '19 19:09 Logerfo