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.Core #46

Closed MortInfinite closed 6 years ago

MortInfinite commented 6 years ago

Every time I try to merge any assembly, I am presented with the following exception:

An exception occurred during merging:
Unresolved assembly reference not allowed: System.Core.
   at System.Compiler.Ir2md.GetAssemblyRefIndex(AssemblyNode assembly)
   at System.Compiler.Ir2md.GetTypeRefIndex(TypeNode type)
   at System.Compiler.Ir2md.WriteTypeDefOrRefEncoded(BinaryWriter target, TypeNode type)
   at System.Compiler.Ir2md.WriteTypeSignature(BinaryWriter target, TypeNode type, Boolean instantiateGenericTypes)
   at System.Compiler.Ir2md.WriteTypeSignature(BinaryWriter target, TypeNode type, Boolean instantiateGenericTypes)
   at System.Compiler.Ir2md.GetBlobIndex(TypeNode type)
   at System.Compiler.Ir2md.GetTypeSpecIndex(TypeNode type)
   at System.Compiler.Ir2md.VisitReferencedType(TypeNode type)
   at System.Compiler.Ir2md.GetMemberRefIndex(Member m)
   at System.Compiler.Ir2md.GetMethodToken(Method m)
   at System.Compiler.Ir2md.VisitConstruct(Construct cons)
   at System.Compiler.Ir2md.VisitAssignmentStatement(AssignmentStatement assignment)
   at System.Compiler.Ir2md.VisitBlock(Block block)
   at System.Compiler.Ir2md.VisitBlock(Block block)
   at System.Compiler.Ir2md.VisitMethodBody(Method method)
   at System.Compiler.Ir2md.VisitMethod(Method method)
   at System.Compiler.Ir2md.VisitClass(Class Class)
   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 ILMerging.ILMerge.Merge()
   at ILMerging.ILMerge.Main(String[] args)

The command line arguments I'm using look like this: ilmerge.exe /out:Result.exe Input1.exe Input2.dll

I have tried multiple combinations of my assemblies and all of them produce this exception. System.Core is a part of the .NET framework and I'm not specifying to merge this assembly.

mike-barnett commented 6 years ago

It could be that you need to specify the target platform: what version of .NET are Input1.exe and Input2.dll built against? You can see what the default target platform is that ILMerge is using if you add "/log:foo.txt" to the command line arguments.

MortInfinite commented 6 years ago

Thank you, specifying framework v4 allowed me to continue the merge operation 👍 (The log said that It previously defaulted to v2).