il-repack
il-repack copied to clipboard
CoreCLR support
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.
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.
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.
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.