gluck / il-repack

Open-source alternative to ILMerge
Apache License 2.0
1.19k stars 217 forks source link

Failed to resolve System.Reflection.BindingFlags #285

Closed ran1904 closed 11 months ago

ran1904 commented 3 years ago

Hey Im trying to merge two dlls file as postbuild event this is the command :

IF $(ConfigurationName) == Release "$(SolutionDir)Isolator\build\Binaries\ilrepack\2.0.18\tools\ILRepack.exe" /log:"$(TargetDir)ILRepack\MergeLogTypemock_Configuration.txt" /out:"$(TargetDir)ILRepack\TypeMock.dll" /internalize "$(TargetDir)TypeMock.dll" "$(TargetDir)Configuration.dll" /keyfile:"$(SolutionDir)Isolator\TypeMock.Framework\TypeMock.Core\KeyPair.snk"

and log output:

INFO: IL Repack - Version 2.0.18 INFO: ------------- IL Repack Arguments ------------- /out:C:\Users\ran\Desktop\CoreRepo\Output\AnyCPU\Release\PublicAssemblies\netcoreapp2.1\ILRepack\TypeMock.dll /keyfile:C:\Users\ran\Desktop\CoreRepo\Isolator\TypeMock.Framework\TypeMock.Core\KeyPair.snk /internalize C:\Users\ran\Desktop\CoreRepo\Output\AnyCPU\Release\PublicAssemblies\netcoreapp2.1\TypeMock.dll C:\Users\ran\Desktop\CoreRepo\Output\AnyCPU\Release\PublicAssemblies\netcoreapp2.1\Configuration.dll

INFO: Adding assembly for merge: C:\Users\ran\Desktop\CoreRepo\Output\AnyCPU\Release\PublicAssemblies\netcoreapp2.1\TypeMock.dll INFO: Adding assembly for merge: C:\Users\ran\Desktop\CoreRepo\Output\AnyCPU\Release\PublicAssemblies\netcoreapp2.1\Configuration.dll INFO: Processing references INFO: Processing types INFO: Merging INFO: Merging INFO: Processing exported types INFO: Processing resources INFO: Fixing references Mono.Cecil.ResolutionException: Failed to resolve System.Reflection.BindingFlags at Mono.Cecil.Mixin.CheckedResolve(TypeReference self) at Mono.Cecil.MetadataBuilder.GetConstantType(TypeReference constant_type, Object constant) at Mono.Cecil.MetadataBuilder.AddConstant(IConstantProvider owner, TypeReference type) at Mono.Cecil.MetadataBuilder.AddField(FieldDefinition field) at Mono.Cecil.MetadataBuilder.AddFields(TypeDefinition type) at Mono.Cecil.MetadataBuilder.AddType(TypeDefinition type) at Mono.Cecil.MetadataBuilder.AddTypeDefs() at Mono.Cecil.MetadataBuilder.BuildTypes() at Mono.Cecil.MetadataBuilder.BuildModule() at Mono.Cecil.ModuleWriter.BuildMetadata(ModuleDefinition module, MetadataBuilder metadata) at Mono.Cecil.ModuleWriter.WriteModuleTo(ModuleDefinition module, Stream stream, WriterParameters parameters) at Mono.Cecil.ModuleDefinition.Write(String fileName, WriterParameters parameters) at ILRepacking.ILRepack.Repack() at ILRepacking.Application.Main(String[] args)

any solutions?

sinai-dev commented 2 years ago

The solution is to make sure you reference .NET 6 mscorlib in your lib.

You should be able to find it somewhere like this: C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.4\ref\net6.0

KirillOsenkov commented 11 months ago

Please try the latest version