gluck / il-repack

Open-source alternative to ILMerge
Apache License 2.0
1.16k stars 214 forks source link

Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly protobuf-net #125

Closed thefringeninja closed 8 months ago

thefringeninja commented 9 years ago

I want to update from ilmerge to ilrepack: https://github.com/thefringeninja/EventStore/tree/ilrepack

I tried to create a small repro with a single .net 4.0 project referencing protobuf-net 2.0.0.594 but couldn't reproduce it.

Here is the output:

INFO: IL Repack - Version 2.0.5 INFO: Target platform directory resolved to C:\Windows\Microsoft.NET\Framework64\v4.0.30319 INFO: Adding assembly for merge: .\bin\clientapiembedded\EventStore.ClientAPI.Embedded.dll INFO: Adding assembly for merge: .\bin\clientapiembedded\EventStore.BufferManagement.dll INFO: Adding assembly for merge: .\bin\clientapiembedded\EventStore.Common.dll INFO: Adding assembly for merge: .\bin\clientapiembedded\EventStore.Core.dll ERROR: Failed to load assembly .\bin\clientapiembedded\EventStore.Core.dll Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'protobuf-net, Version=2.0.0.594, Culture=neutral, PublicKeyToken=257b51d87d2e4d67' at Mono.Cecil.BaseAssemblyResolver.Resolve(AssemblyNameReference name, ReaderParameters parameters) at Mono.Cecil.DefaultAssemblyResolver.Resolve(AssemblyNameReference name) at Mono.Cecil.MetadataResolver.Resolve(TypeReference type) at Mono.Cecil.SignatureReader.ReadCustomAttributeEnum(TypeReference enum_type) at Mono.Cecil.SignatureReader.ReadCustomAttributeElement(TypeReference type) at Mono.Cecil.SignatureReader.ReadCustomAttributeNamedArgument(Collection1& fields, Collection1& properties) at Mono.Cecil.SignatureReader.ReadCustomAttributeNamedArguments(UInt16 count, Collection1& fields, Collection1& properties) at Mono.Cecil.CustomAttribute.b34_0(CustomAttribute attribute, MetadataReader reader) at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func3 read) at Mono.Cecil.CustomAttribute.get_ConstructorArguments() at Mono.Cecil.ImmediateModuleReader.ReadCustomAttributes(ICustomAttributeProvider provider) at Mono.Cecil.ImmediateModuleReader.ReadFields(TypeDefinition type) at Mono.Cecil.ImmediateModuleReader.ReadType(TypeDefinition type) at Mono.Cecil.ImmediateModuleReader.ReadTypes(Collection1 types) at Mono.Cecil.ImmediateModuleReader.ReadType(TypeDefinition type) at Mono.Cecil.ImmediateModuleReader.ReadTypes(Collection`1 types) at Mono.Cecil.ImmediateModuleReader.ReadModule(ModuleDefinition module) at Mono.Cecil.ImmediateModuleReader.b1_0(ModuleDefinition module, MetadataReader reader)

at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func`3 read) at Mono.Cecil.ModuleReader.CreateModuleFrom(Image image, ReaderParameters parameters) at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters) at Mono.Cecil.AssemblyDefinition.ReadAssembly(String fileName, ReaderParameters parameters) at ILRepacking.ILRepack.ReadInputAssembly(String assembly, Boolean isPrimary) at ILRepacking.ILRepack.ReadInputAssemblies() at ILRepacking.ILRepack.Repack() at ILRepacking.Application.Main(String[] args)

gregoryyoung commented 9 years ago

I have dealt quite a bit with cecil... does il-repack use a custom resolver for cecil? Looking quickly over the code I see https://github.com/gluck/il-repack/blob/master/ILRepack/RepackAssemblyResolver.cs but this appears to just be default cecil behaviour.

As I understand @thefringeninja has this assembly in the same directory.

gluck commented 9 years ago

What's the (full) ILRepack command (and version) you're using ? Supposedly ILRepack looks for assembly references in provided /lib folder but also merged assemblies folders.

If it still doesn't work and all the assemblies you're trying to merge are open-source (or at least nuget-available), you can provide the list of packages and command you're running and I'll write the integration test for it (tl;dr no need to try to get smaller than that in the reproduction path).

KirillOsenkov commented 8 months ago

The latest version should have a resolver that's working better now.