gluck / il-repack

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

Option to exclude external assembly #212

Closed FixRM closed 8 months ago

FixRM commented 6 years ago

Hi. I'm getting the error "Failed to resolve assembly" during merge. The problem is that I don't need this assembly to be merged as it will be available in target environment.

lextm commented 6 years ago

Let ILRepack be able to resolve an assembly (so that Mono Cecil can read the metadata), and that does not mean you need to merge that assembly with others. I think you just misunderstood the concepts.

FixRM commented 6 years ago

How can I do this? This assembly is available in the same folder as my. What should I do to let ILRepack to be able to resolve it?

p.s. ILMerge is ok with that so I consider this is an ILRepack issue/feature

deniszykov commented 6 years ago

if it is .NET Framework assembly you could specify path to Framework's location "/targetplatform:v4,<PATHTOFRAMEWORK>"

FixRM commented 6 years ago

No it is part of MS Dynamics 365 SDK. The problem is that target system use reflection to create instance of my classes, so they must be extended from external type which is part of SDK assembly

gluck commented 6 years ago

You may need to specify /lib:<FOLDER_INCLUDING_THE_ASSEMBLY>. I didn't think it was required if the assembly was in the same folder of one of the assemblies you're trying to merge, but give it a try already.

FixRM commented 6 years ago

It looks like it work. Error has gone and I don't see SDK assembly classes using reflector. May I suggest it is still a bug?

gluck commented 6 years ago

It looks like it has never been the case, it could be implemented though. cf https://github.com/gluck/il-repack/blob/3829e3db36ffbf511fcec05316bbf36b33ce83fb/ILRepack/ILRepack.cs#L391

honzakostejn commented 5 years ago

Hello there! I have the same issue. We are developing Model-driven apps on Microsoft PowerPlatform (re-branded dynamics). We were using ILMerge and it worked just fine, until we switched to the new .csproj structure. Can someone help me out?

I'm using ILRepack 2.0.16. I'm referencing a few projects and two other nugget packages: image

My .csproj looks like this: image

With this setup, I'm encountering the same issue: image

Based on this thread, I tried this: image

And got this result: image

But I have no luck with this setup. Am I doing something wrong? Thanks for help. <3

FixRM commented 5 years ago

Hello @honzakostejn,

I use this tool for the same purpose. I highly recommend you to use this MSBuild taks: https://github.com/ravibpatel/ILRepack.Lib.MSBuild.Task. You can see sample config here: https://github.com/FixRM/D365Extensions

honzakostejn commented 5 years ago

@FixRM,

thanks a lot! I'll definitely go through your repo.

But I managed to solve my issue today. I just tweaked .csproj a little. It works just fine. I'll write short blogpost and post it here, if someone had the same issue.

wh1t3cAt1k commented 2 years ago

@honzakostejn my friend, I need your blog post so desperately...

honzakostejn commented 2 years ago

@wh1t3cAt1k I'll try to whip it back online... :)

update: I've republished the blogpost: https://blog.thenetw.org/2019/01/10/how-to-merge-assemblies-cds/

KirillOsenkov commented 8 months ago

The resolver has been improved in the latest version, please try the latest and open a new bug if there's still an ILRepack issue. Thanks.