7272927785
Former-commit-id: 6d37e02debfe41dd5c13ba6f6a2428c8b1ff5e28
64 lines
1.2 KiB
C#
64 lines
1.2 KiB
C#
//
|
|
// mono-cil-strip
|
|
//
|
|
// Author(s):
|
|
// Jb Evain (jbevain@novell.com)
|
|
//
|
|
// Copyright (C) 2008 Novell, Inc (http://www.novell.com)
|
|
//
|
|
|
|
using System;
|
|
using System.Reflection;
|
|
|
|
using Mono.Cecil;
|
|
|
|
namespace Mono.CilStripper {
|
|
|
|
class Program {
|
|
|
|
static int Main (string [] args)
|
|
{
|
|
Header ();
|
|
|
|
if (args.Length == 0)
|
|
Usage ();
|
|
|
|
string file = args [0];
|
|
string output = args.Length > 1 ? args [1] : file;
|
|
|
|
try {
|
|
AssemblyDefinition assembly = AssemblyFactory.GetAssembly (file);
|
|
StripAssembly (assembly, output);
|
|
|
|
if (file != output)
|
|
Console.WriteLine ("Assembly {0} stripped out into {1}", file, output);
|
|
else
|
|
Console.WriteLine ("Assembly {0} stripped", file);
|
|
return 0;
|
|
} catch (TargetInvocationException tie) {
|
|
Console.WriteLine ("Error: {0}", tie.InnerException);
|
|
} catch (Exception e) {
|
|
Console.WriteLine ("Error: {0}", e);
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
static void StripAssembly (AssemblyDefinition assembly, string output)
|
|
{
|
|
AssemblyStripper.StripAssembly (assembly, output);
|
|
}
|
|
|
|
static void Header ()
|
|
{
|
|
Console.WriteLine ("Mono CIL Stripper");
|
|
Console.WriteLine ();
|
|
}
|
|
|
|
static void Usage ()
|
|
{
|
|
Console.WriteLine ("Usage: mono-cil-strip file [output]");
|
|
Environment.Exit (1);
|
|
}
|
|
}
|
|
}
|