dotnet / ILMerge

ILMerge is a static linker for .NET Assemblies.
MIT License
1.23k stars 170 forks source link

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

Open Logerfo opened 5 years ago

Logerfo commented 5 years ago

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)

mike-barnett commented 5 years ago

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.

Logerfo commented 5 years ago

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?

mike-barnett commented 5 years ago

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?

Logerfo commented 5 years ago

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

mike-barnett commented 5 years ago

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.

Logerfo commented 5 years ago

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.