Hi all,
I've just written the ILASM task, but it does not work
(of course, I'm doing something wrong).
Giving the following build file:
<project name="OddOrEven" default="build">
<target name="build">
<ilasm target="exe" output="OddOrEven.exe">
<sources basedir=".">
<include name="MainClass.il"/>
</sources>
</ilasm>
</target>
</project>
... the output is:
[ilasm] Compiling 3 files to
'C:\Home\Projects\temp\.net\ilasm\OddOrEven\OddOrEven.exe'.
Microsoft (R) .NET Framework IL Assembler. Version 1.1.4322.573
Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.
Assembling '@C:\DOCUME~1\GGRECO~1.ECH\LOCALS~1\Temp\tmpB13.tmp' ,
no listing file, to EXE -->
'@C:\DOCUME~1\GGRECO~1.ECH\LOCALS~1\Temp\tmpB13.EXE'
Could not open @C:\DOCUME~1\GGRECO~1.ECH\LOCALS~1\Temp\tmpB13.tmp
***** FAILURE *****
It looks like the CompilerBase class is not able to find
the source files. Attached to this email you'll find the
IlasmTask.cs file... What am I missing?
Thanks,
j3d.
----------------------------------------
Giuseppe Greco
::agamura::
phone: +41 (0)91 604 67 65
mobile: +41 (0)76 390 60 32
email: [EMAIL PROTECTED]
web: www.agamura.com
----------------------------------------
// NAnt - A .NET build tool
// Copyright (C) 2001-2002 Gerry Shaw
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Giuseppe Greco ([EMAIL PROTECTED])
using System.IO;
using System.Text.RegularExpressions;
using NAnt.Core;
using NAnt.Core.Attributes;
using NAnt.Core.Types;
using NAnt.Core.Util;
namespace NAnt.DotNet.Tasks {
/// <summary>
/// Compiles ILASM programs.
/// </summary>
/// <example>
/// <para>Compiles <c>helloworld.il</c> to <c>helloworld.exe</c>.</para>
/// <code>
/// <![CDATA[
/// <ilasm target="exe" output="helloworld.exe" debug="true">
/// <sources>
/// <include name="helloworld.il" />
/// </sources>
/// </ilasm>
/// ]]>
/// </code>
/// </example>
[TaskName("ilasm")]
[ProgramLocation(LocationType.FrameworkDir)]
public class IlasmTask : CompilerBase {
#region Private Instance Fields
private bool _listing;
private bool _noLogo;
private bool _quiet;
private bool _clock;
// private FileInfo _keyFile;
// private string _keySource;
private string _subsystem;
private string _flags;
private string _alignment;
private string _base;
private bool _error;
#endregion Private Instance Fields
#region Private Static Fields
private static Regex _classNameRegex =
new
Regex(@"^((?<comment>/\*.*?(\*/|$))|[\s\.\{]+|class\s+(?<class>\w+)|(?<keyword>\w+))*");
private static Regex _namespaceRegex =
new
Regex(@"^((?<comment>/\*.*?(\*/|$))|[\s\.\{]+|namespace\s+(?<namespace>(\w+(\.\w+)*)+)|(?<keyword>\w+))*");
#endregion Private Static Fields
#region Public Instance Properties
/// <summary>
/// Specifies whether the compiler should type a formatted listing of
/// the compilation result. The default is <see langword="false" />.
/// </summary>
/// <remarks>
/// <para>
/// Corresponds to the <c>/LISTING</c> flag.
/// </para>
/// </remarks>
[TaskAttribute("listing")]
[BooleanValidator()]
public bool Listing {
get { return _listing; }
set { _listing = value; }
}
/// <summary>
/// Specifies whether the compiler should suppress logo and copyright
/// statements. The default is <see langword="false" />.
/// </summary>
/// <remarks>
/// <para>
/// Corresponds to the <c>/NOLOGO</c> flag.
/// </para>
/// </remarks>
[TaskAttribute("nologo")]
[BooleanValidator()]
public bool NoLogo {
get { return _noLogo; }
set { _noLogo = value; }
}
/// <summary>
/// Specifies whether the compiler should suppress the compilation
/// progress report. The default is <see langword="false" />.
/// </summary>
/// <remarks>
/// <para>
/// Corresponds to the <c>/QUIET</c> flag.
/// </para>
/// </remarks>
[TaskAttribute("quiet")]
[BooleanValidator()]
public bool Quiet {
get { return _quiet; }
set { _quiet = value; }
}
/// <summary>
/// Specifies whether the compiler should measure and report the
/// compilation times. The default is <see langword="false" />.
/// </summary>
/// <remarks>
/// <para>
/// Corresponds to the <c>/CLOCK</c> flag.
/// </para>
/// </remarks>
[TaskAttribute("clock")]
[BooleanValidator()]
public bool Clock {
get { return _clock; }
set { _clock = value; }
}
/// <summary>
/// Instructs the compiler to set the <i>Subsystem</i> value in the PE
/// header. The most frequently value are 3 (console application) and
/// 2 (GUI application).
/// </summary>
/// <remarks>
/// <para>
/// Corresponds to the <c>/SUBSYSTEM</c> flag.
/// </para>
/// </remarks>
[TaskAttribute("subsystem")]
public string Subsystem {
get { return _subsystem; }
set { _subsystem = value; }
}
/// <summary>
/// Instructs the compiler to set the <i>Flags</i> value in the CLR
/// header. The most frequently value are 1 (pre-IL code) and 2
/// (mixed code). The third bit indicating that the PE file is
/// strong signed, is ignored.
/// </summary>
/// <remarks>
/// <para>
/// Corresponds to the <c>/FLAGS</c> flag.
/// </para>
/// </remarks>
[TaskAttribute("flags")]
public string Flags {
get { return _flags; }
set { _flags = value; }
}
/// <summary>
/// Instructs the compiler to set the <i>FileAlignment</i> value in
/// the PE header. The value must be a power of 2, in range from 512
/// to 65536.
/// </summary>
/// <remarks>
/// <para>
/// Corresponds to the <c>/ALIGNMENT</c> flag.
/// </para>
/// </remarks>
[TaskAttribute("alignment")]
public string Alignment {
get { return _alignment; }
set { _alignment = value; }
}
/// <summary>
/// Instructs the compiler to set the <i>ImageBase</i> value in
/// the PE header.
/// </summary>
/// <remarks>
/// <para>
/// Corresponds to the <c>/BASE</c> flag.
/// </para>
/// </remarks>
[TaskAttribute("base")]
public string Base {
get { return _base; }
set { _base = value; }
}
/// <summary>
/// Specifies whether the compiler should attempt to create a PE file
/// even if compilation errors have been reported. The default is
/// <see langword="false" />.
/// </summary>
/// <remarks>
/// <para>
/// Corresponds to the <c>/ERROR</c> flag.
/// </para>
/// </remarks>
[TaskAttribute("error")]
[BooleanValidator()]
public bool Error {
get { return _error; }
set { _error = value; }
}
#endregion Public Instance Properties
#region Override implementation of CompilerBase
/// <summary>
/// Writes the compiler options to the specified <see cref="TextWriter" />.
/// </summary>
/// <param name="writer">
/// <see cref="TextWriter" /> to which the compiler options should be
/// written.
/// </param>
protected override void WriteOptions(TextWriter writer) {
if (Listing) {
WriteOption(writer, "listing");
}
if (NoLogo) {
WriteOption(writer, "nologo");
}
if (Quiet) {
WriteOption(writer, "quiet");
}
if (Debug) {
WriteOption(writer, "debug");
WriteOption(writer, "define", "DEBUG");
WriteOption(writer, "define", "TRACE");
}
if (Clock) {
WriteOption(writer, "clock");
}
if (Subsystem != null) {
WriteOption(writer, "subsystem", Subsystem);
}
if (Flags != null) {
WriteOption(writer, "flags", Flags);
}
if (Alignment != null) {
WriteOption(writer, "alignment", Alignment);
}
if (Base != null) {
WriteOption(writer, "base", Base);
}
if (Error) {
WriteOption(writer, "error");
}
}
/// <summary>
/// Gets the file extension required by the current compiler.
/// </summary>
/// <value>
/// For the ILASM compiler, the file extension is always <c>il</c>.
/// </value>
public override string Extension {
get { return "il"; }
}
/// <summary>
/// Gets the class name regular expression for the language of the
/// current compiler.
/// </summary>
/// <value>
/// Class name regular expression for the language of the current
/// compiler.
/// </value>
protected override Regex ClassNameRegex {
get { return _classNameRegex; }
}
/// <summary>
/// Gets the namespace regular expression for the language of the current
compiler.
/// </summary>
/// <value>
/// Namespace regular expression for the language of the current
/// compiler.
/// </value>
protected override Regex NamespaceRegex {
get { return _namespaceRegex; }
}
#endregion Override implementation of CompilerBase
}
}