5 // Jb Evain (jbevain@novell.com)
7 // Copyright (C) 2008 Novell, Inc (http://www.novell.com)
12 using System
.Reflection
;
16 namespace Mono
.CilStripper
{
20 static void Main (string [] args
)
27 string file
= args
[0];
28 string output
= args
.Length
> 1 ? args
[1] : file
;
31 AssemblyDefinition assembly
= AssemblyFactory
.GetAssembly (file
);
32 StripAssembly (assembly
, output
);
35 Console
.WriteLine ("Assembly {0} stripped out into {1}", file
, output
);
37 Console
.WriteLine ("Assembly {0} stripped", file
);
38 } catch (TargetInvocationException tie
) {
39 Console
.WriteLine ("Error: {0}", tie
.InnerException
);
40 } catch (Exception e
) {
41 Console
.WriteLine ("Error: {0}", e
);
45 static void StripAssembly (AssemblyDefinition assembly
, string output
)
47 Type stripper
= typeof (AssemblyDefinition
).Assembly
.GetType ("Mono.Cecil.AssemblyStripper");
49 throw new NotSupportedException ("Cecil doesn't have support for mono-cil-strip");
51 stripper
.GetMethod ("StripAssembly").Invoke (null, new object [] { assembly, output }
);
56 Console
.WriteLine ("Mono CIL Stripper");
62 Console
.WriteLine ("Usage: mono-cil-strip file [output]");