Using the reference supplied by Thibaut Barr�re, I was able to code this
function be inserted into FileFunctions.cs in Nant.Core. This function will
return true if the specified file is a .NET assembly and false if it is not.
/// <summary>
/// Returns true if the specified file is a valid .NET assembly
/// </summary>
/// <param name="file">filename</param>
/// <returns>true if it is an assembly, false
otherwise</returns>
/// <exception cref="FileNotFoundException">The file specified
cannot be found.</exception>
[Function("is-assembly")]
public bool IsAssembly(string file)
{
bool result = true; // assume it is an assembly unless
proven otherwise
try
{
AssemblyName.GetAssemblyName(Project.GetFullPath(file));
}
catch (BadImageFormatException)
{
result = false;
}
return result;
}
Here is a test .build file to check that this works:
<?xml version="1.0" ?>
<project name="assembly" default="test">
<property name="IsAnAssembly" value="C:\Program
Files\NAnt\bin\NAnt.DotNetTasks.dll"/>
<property name="NotAnAssembly" value="C:\WINDOWS\system32\Mapi32.dll"/>
<target name="test">
<if test="${file::is-assembly(IsAnAssembly)}">
<echo message="${IsAnAssembly} is an assembly"/>
</if>
<ifnot test="${file::is-assembly(NotAnAssembly)}">
<echo message="${NotAnAssembly} is not an assembly"/>
</ifnot>
</target>
</project>
You can decide if it should be in FileFunctions or AssemblyFunctions.
Stephen Lewis
Envisioneering LLC - Medical Products
St. Louis, MO 63114
(314) 429-7367 x112
-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE
FREE OODBMS DOWNLOAD - A multidimensional database that combines
robust object and relational technologies, making it a perfect match
for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
_______________________________________________
Nant-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-users