Ildasm Task

Description

Task to take a .NET or Mono -generated managed executable and turn it into ILASM assembly code. Useful when converting imported typelibs into assembler before patching and recompiling, as one has to do when doing advanced typelib work.

As well as generating the named output file, the ildasm program will also generate resource files Icons.resources Message.resources and a .res file whose filename stub is derived from the source in ways to obscure to determine. There is no way to control whether or not these files are created, or where they are created (they are created in the current directory; their names come from inside the executable and may be those used by the original developer). This task creates the resources in the directory specified by resourceDir if set, else in the same directory as the destFile.

This task requires the .NET SDK installed and ildasm on the path. To disassemble using alternate CLR systems, set the executable attribute to the name/path of the alternate implementation -one that must support all the classic ildasm commands. Note: the ildasm executable of version 2.0 of Microsoft's .NET SDK seems to be broken as it always failed during tests (couldn't find the assembly's metadata) even for assemblies built completely independent of Ant.

Dependency logic: the task executes the command if the output file is missing or older than the source file. It does not take into account changes in the options of the task, or timestamp differences in resource files. When the underlying ildasm executable fails for some reason, it leaves the .il file in place with some error message. To prevent this from confusing the dependency logic, the file specified by the dest attribute is always deleted after an unsuccessful build.

Parameters

Attribute Description Type Requirement
assembler enable (default) or disable assembly language in the output boolean Optional
bytes enable or disable (default) the original bytes as comments boolean
destfile the output file (required) File
encoding Select the output encoding: ascii, utf8 or unicode "ascii", "utf8", "unicode"
executable override the name of the executable (normally ildasm) or set its full path. Do not set a relative path, as the ugly hacks needed to create resource files in the dest directory force us to change to this directory before running the application. i.e use <property location> to create an absolute path from a relative one before setting this value. String
header include header information; default false. boolean
item name a single item to decode; a class or a method e.g item="Myclass::method" or item="namespace1::namespace2::Myclass:method(void(int32)) String
linenumbers include line number information; default=false boolean
metadata include metadata information boolean
progressbar show a graphical progress bar in a window during the process; off by default boolean
quoteallnames quote all names. boolean
rawexceptionhandling enable raw exception handling (default = false) boolean
resourcedir Set the name of the directory for resources to be created. We cannot control their names, but we can say where they get created. If not set, the directory of the dest file is used File
showsource include the source as comments (default=false) boolean
sourcefile the file to disassemble -required File
srcfile alternate name for sourceFile File
visibility visibility options: one or more of the following, with + signs to concatenate them:
 pub : Public pri : Private
          fam : Family asm : Assembly faa : Family and Assembly foa :
          Family or Assembly psc : Private Scope 
e.g. visibility="pub+pri". Family means protected in C#;
String