Lokad / ILPack

Serialize .NET Core assemblies

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add equivalent of AssemblyBuilder.SetEntryPoint

johndaintree opened this issue · comments

I've just discovered that AssemblyBuilder.SetEntryPoint is not available in .NET >= 5. I wonder/hope if its functionality is something that could be included in ILPAck.

https://docs.microsoft.com/en-us/dotnet/api/system.reflection.emit.assemblybuilder.setentrypoint?view=netframework-4.8

Hi @johndaintree, yes this feature is reasonable. I don't have the resources at the moment to work on this, but don't hesitate to submit a PR.

Hi @johndaintree, yes this feature is reasonable. I don't resources at the moment to work on this, but don't hesitate to submit a PR.

Thanks @vermorel , I'm glad to hear that this is reasonable. I'm new to github, so I'll figure out how to do it and submit a PR. Thanks, again.

hi @johndaintree , it seems like I'm early because I also need to set an entry point xD any idea on when you might finish that feature? or how I could work around it for now?

hi @johndaintree , it seems like I'm early because I also need to set an entry point xD any idea on when you might finish that feature? or how I could work around it for now?

Hi @gluckez. I've not had a chance to look at it yet, and I don't know when I will. I've no idea what will be required, nor do I have a workaround. When I start I can post here, in the meantime feel free to take a look yourself.

Wondering if anyone's made any progress on this or heard of alternative implementations?

Looking into it, I believe that an alternate GenerateAssemblyBytes can be provided that then uses the provided MethodInfo to lookup the MethodBaseDefinitionMetadata in _methodDefHandles in AssemblyMetadata to then set the entryPoint inside GenerateAssemblyBytes with the handle obtained from that.

I'll test this soon to see if it works out.

Have opened a PR, if you can check it out whenever possible @vermorel, I'll be grateful!

Apparently this is finally coming to AssemblyBuilder in .NET 9
dotnet/core#9089 (comment)

Apparently this is finally coming to AssemblyBuilder in .NET 9 dotnet/core#9089 (comment)

Doesn't seem to have SetEntryPoint for now (at least it hasn't been implemented so far, but we have 9 months still).

And hopefully we get PDB support soon as well, I really don't want to find out how to write those 😓