Easy way to modify IL code

Sometimes I try to write a little bit of IL code or modify bits and pieces here and there (specially modify IL generated from say C# code).

The problem is writing up the complete IL that compiles into an exe is a pain (specially because my usage is to tweak them). To work around this I use the following flow which I thought I'd share

  1. Write C# code that meets the need
  2. Build it
  3. Disassemble the exe by using the following command
    ildasm /out=file.il My.exe 
  4. Tweak the IL inside the file.il file
  5. Assemble it back again with
    ilasm file.il

the neat part is the /out parameter which makes ildasm dump a single IL for the entire code. At the beginning I used to try patching the code up by copy-pasting from ILDASM UI which show separate IL code for every method :(