ILMerge icon indicating copy to clipboard operation
ILMerge copied to clipboard

dotnet-ilmerge

Open natemcmaster opened this issue 8 years ago • 11 comments

Would be awesome to make ilmerge available as a command line tool along with the .NET Core CLI.

Details on extending the CLI: https://docs.microsoft.com/en-us/dotnet/articles/core/tools/extensibility

natemcmaster avatar Apr 21 '17 16:04 natemcmaster

That sounds great. I looked at the details: do you think it should be extended in all 3 ways that the document describes?

mike-barnett avatar Apr 21 '17 17:04 mike-barnett

  1. Via NuGet packages on a per-project basis
  2. Via NuGet packages with custom targets
  3. Via the system's PATH

I would recommend 2 for sure. 1 is more effort but likely worth it. 3 has less value at the moment as ILMerge is already a console tool. Adding PATH means users can just run ilmerge.exe instead of dotnet.exe ilmerge.

By the way, I'd be happy to make a PR if you would take it.

natemcmaster avatar Apr 21 '17 17:04 natemcmaster

Sure! Even better...

mike-barnett avatar Apr 21 '17 17:04 mike-barnett

Ok. I'll make a PR for item 2. Item 1 might take more effort so I'l do that separately.

natemcmaster avatar Apr 21 '17 17:04 natemcmaster

There is enough compatible API that I don't think this tool will run on .NET Core 1.x without major rewrites. I took a wack at compiling ILMerge for .NET Core 2.0 (not released yet). However, it's almost compatible with .NET Core 2.0. There is only one incompatible API. Marshal.GetTypedObjectForIUnknown.

Nodes.cs(752,71): error CS0117: 'Marshal' does not contain a definition for 'GetTypedObjectForIUnknown' [C:\dev\ILMerge\System.Compiler\System.Compiler.csproj]
Reader.cs(2258,73): error CS0117: 'Marshal' does not contain a definition for 'GetTypedObjectForIUnknown' [C:\dev\ILMerge\System.Compiler\System.Compiler.cspro
j]
Reader.cs(2280,70): error CS0117: 'Marshal' does not contain a definition for 'GetTypedObjectForIUnknown' [C:\dev\ILMerge\System.Compiler\System.Compiler.cspro
j]

See https://github.com/natemcmaster/ILMerge/commit/aa1daf963c2bd8466b7b413c9dd395e9c02b7234

natemcmaster avatar Apr 21 '17 21:04 natemcmaster

@natemcmaster What about Marshal.GetObjectForIUnknown(IntPtr pUnk) as replacement?

Fabi avatar Apr 28 '17 12:04 Fabi

@Fabi I'm not actually sure what either of those APIs do. I'd have to take a closer look at what this code is doing.

Also, some of these more-obscure interop APIs may be present, but will throw PlatformNotSupported on non-Windows platforms. See https://github.com/dotnet/corefx/blob/0e718a78b591dfbd46ccd7ac9411d15c4cdb46eb/src/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/MarshalTests.cs#L315-L325

natemcmaster avatar Apr 28 '17 16:04 natemcmaster

Any progress on this again?

mieliespoor avatar Aug 02 '18 10:08 mieliespoor

@mike-barnett and I started looking at this but it fell off my radar. At this point, I would actually recommend making it a .NET Core 2.1 global tool instead of a project tool named dotnet-ilmerge. The tool's usage doesn't need to hang off "dotnet" anymore. It could just be:

$ dotnet tool install -g ilmerge
$ ilmerge One.dll Two.dll

Thoughts? @mike-barnett

natemcmaster avatar Aug 02 '18 15:08 natemcmaster

That actually makes more sense.

mieliespoor avatar Aug 02 '18 17:08 mieliespoor

Fine by me! Let me know if there's anything you need from me.

mike-barnett avatar Aug 06 '18 17:08 mike-barnett