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

CoreCLR support

Open iskiselev opened this issue 5 years ago • 2 comments

With CoreCLR 2.0 it is possible to run .NET Framework assemblies with CoreCLR, if they do not use anything not implemented in CoreCLR, It means, that there is a chance that ILRepack will work on CoreCLR without recompilation, and I've tested it. For test, in ILRepack.exe folder I've created ILRepack.runtimeconfig.json with next content:

{
  "runtimeOptions": {
    "tfm": "netcoreapp2.1",
    "framework": {
      "name": "Microsoft.NETCore.App",
      "version": "2.1.0"
    }
  }
}

After it, I run it using dotnet ILRepack.exe ... command. And per my tests, it works! Unfortunately now it works on windows - as on unix environment it does Syscall.stat / Syscall.chmod, which are provided by mono and not exists in CoreCLR and crash after it. To make it experimental runnable on Linux CoreCLR, we should call Mono API only when we are executed on mono.

iskiselev avatar Nov 06 '18 21:11 iskiselev

Good idea, but I think .NET Core migration should be a continuation of https://github.com/gluck/il-repack/pull/236

With unforked Mono.Cecil we can upgrade ILRepack projects to new csproj format and use multitargeting to build net40 and netcoreapp2.1 assemblies together. Also after migration we can distribute ILRepack as .NET Core Global Tool.

Mono POSIX API is available in Mono.Posix.NETStandard package so broken syscalls is not a problem.

The other possible problem is *.pdb srcsrv alternative streams merging which is done by windows-only tool. I expect that is not a blocker for experimental version.

epeshk avatar Nov 12 '18 15:11 epeshk

I'm looking on #236, and hope it will be merged soon (it will unblock so many things: portable pdb support, netstandard migration and so on). I agree that in long-term creating .Net Core Global tool package will be proper choice. There may be some smaller obstacles, but all of them are solvable. For example Mono.Posix.NETStandard do not provide linux-musl native library now, so there is a high chance that it won't work on Alpine. In short term, I see that currently ILRepack expect, that if it was executed on Linux, it was executed on Mono - and in general it is not correct, so I tried to solve it with my PR #239 that will also unblock users that try to execute current ILRepack version on Linux / CoreCLR.

iskiselev avatar Nov 12 '18 22:11 iskiselev

We have now released 2.0.22 which should support Unit and .NET 6/7/8: https://github.com/gluck/il-repack/releases/tag/2.0.22

You can now run either dotnet ILRepack.exe or mono ILRepack.exe on Unix.

I have removed the dependency on Mono.Posix and shelling out to stat and chmod instead. Mono.Posix.Netstandard wouldn't have helped as it requires shipping a bunch of native platform binaries, and we are rewriting to ship a single standalone ILRepack.exe.

We are skipping source server info on non-Windows and emitting a warning.

KirillOsenkov avatar Jan 01 '24 23:01 KirillOsenkov