gluck / il-repack

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

Feature request: AL 'embed' replacement #374

Closed leppie closed 2 months ago

leppie commented 2 months ago

Add support for /embed flags as used by AL.

This basically just adds manifest resources.

Flag syntax:

file[,name]

Example:

/embed:"..\netcoreapp2.1\IronScheme.FrameworkPAL.dll",core-IronScheme.FrameworkPAL.dll

Realworld example:

I use this to just combine a bunch of files as resources into an assembly (which is later merged).

al /out:IronScheme.PALResources.dll /embed:IronScheme.FrameworkPAL.dll /embed:"..\netcoreapp2.1\IronScheme.FrameworkPAL.dll",core-IronScheme.FrameworkPAL.dll /embed:"..\net9.0\net9-IronScheme.FrameworkPAL.dll"
ilrepack /out:merged\IronScheme.dll IronScheme.dll ... IronScheme.PALResources.dll

Single or double step would be nice.

Note: Adding suggestion as I think it is easy to do and fits in with an assembly modifier.

KirillOsenkov commented 2 months ago

I think this should be a separate tool. ILRepack is not a swiss army knife for metadata, it should do one thing and do it well: merge assemblies.

There are multiple workarounds: as you mention, al exists and does the job.

Additionally, embedding a resource into a .dll is as easy as adding an EmbeddedResource item to the .csproj: https://github.com/KirillOsenkov/MSBuildTools/blob/77d80a2d6d28439666f4620f12d80ddfa5217fe0/src/SimpleResource/SimpleResource.csproj#L9