Re: Determining whether a file is a .NET assembly or not

"Pento, Michael" <[email protected]>
Newsgroups gmane.comp.windows.dotnet.nant.user
Message-ID <F94EF67DFC532744B6AC6719D5FF79C927214068C5@ENTDC1CCR01.metratech.com>
Hi Dominik,

I thought that it might be a bit outside of focus, but, I was taking a gamble that someone knew something about nant that I haven't learned over the past 5 or 6 years.

Thanks very much for the suggested solution, I will try that immediately and let you know how I make out.

Thanks again,
Mike

-----Original Message-----
From: Dominik Guder [mailto:[email protected]] 
Sent: Tuesday, August 31, 2010 5:20 PM
To: [email protected]
Subject: Re: [NAnt-users] Determining whether a file is a .NET assembly or not

Hi,

this is somewhat offtopic here on nant users list.
But since I did this before I will show you a possible solution


Am 30.08.2010 16:55, schrieb Pento, Michael:
> 
> 
> I am trying to loop through a directory filled with about 2,000 DLL's
> and EXE's to see which ones are .NET assemblies.
> 
> Is there a way that I can use from an automation perspective to do this?
> 

I used Mono.Cecil for some reference retreival and needed to skip non
.Net assemblies.

private bool IsNetAssembly(string fileName) {
    Mono.Cecil.Binary.Image img;
    img = Mono.Cecil.Binary.Image.GetImage(fileName);

    if ((img.CLIHeader == null)) {
        return false;
    }
    return true;
}
Hint: This code is using Mono.Cecil 0.6. If you use Mono.Ccil 0.9x then
Mono.Cecil.PE.Image should be used instead of Mono.Cecil.Binary.Image

hth

Dominik

-- 
The answer to the great question of life,
the universe and everything is 42 (Douglas Adams)

------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
NAnt-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nant-users


------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.