I'm trying to set-up a C# project that outputs raw IL code instead of a .EXE. The output file should either look something like this:
IL_0000: nop
IL_0001: ldc.i4.5
IL_0002: stloc.0 // a
IL_0003: ldc.i4.s 18
IL_0005: stloc.1 // b
IL_0006: ldstr "{0} * {1} = {2}"
IL_000B: ldloc.0 // a
IL_000C: box System.Int32
IL_0011: ldloc.1 // b
IL_0012: box System.Int32
IL_0017: ldloc.0 // a
IL_0018: ldloc.1 // b
IL_0019: mul
IL_001A: box System.Int32
IL_001F: call System.Console.WriteLine
IL_0024: nop
IL_0025: ret
...or be the raw binary IL opcodes that can be directly interpreted (or JIT-ed). I'm fine with either option. I tried using ildasm
, however, it says that the .EXE file does not have a valid CLR header. I suspect that ildasm
does not support .NET Core executables, however I may be wrong.