il-repack icon indicating copy to clipboard operation
il-repack copied to clipboard

Option to exclude external assembly

Open FixRM opened this issue 6 years ago • 12 comments

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.

FixRM avatar Nov 15 '17 15:11 FixRM

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.

lextm avatar Nov 16 '17 00:11 lextm

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

FixRM avatar Nov 16 '17 07:11 FixRM

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

deniszykov avatar Nov 16 '17 09:11 deniszykov

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

FixRM avatar Nov 16 '17 10:11 FixRM

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.

gluck avatar Nov 20 '17 09:11 gluck

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?

FixRM avatar Dec 11 '17 10:12 FixRM

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

gluck avatar Jan 02 '18 13:01 gluck

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

honzakostejn avatar Jan 08 '19 17:01 honzakostejn

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

FixRM avatar Jan 09 '19 12:01 FixRM

@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.

honzakostejn avatar Jan 09 '19 18:01 honzakostejn

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

wh1t3cAt1k avatar Feb 11 '22 11:02 wh1t3cAt1k

@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/

honzakostejn avatar Feb 11 '22 15:02 honzakostejn

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.

KirillOsenkov avatar Jan 07 '24 04:01 KirillOsenkov