private static string GetPlatform(Assembly assembly)
{
// TODO Might be other ways to detect this using informational version
Module module = assembly.GetModules(false).FirstOrDefault();
if (module == null)
return "anycpu";
PortableExecutableKinds pe;
ImageFileMachine machine;
module.GetPEKind(out pe, out machine);
if (pe.HasFlag(PortableExecutableKinds.ILOnly))
return "anycpu";
if (pe.HasFlag(PortableExecutableKinds.Unmanaged32Bit))
return "x86";
switch (machine) {
case ImageFileMachine.I386:
return "x86";
case ImageFileMachine.IA64:
case ImageFileMachine.AMD64:
return "x64";
default:
return machine.ToString().ToLowerInvariant();
}
}