**** Merged from MCS ****
[mono-project.git] / mcs / nant / src / Tasks / ExecTask.cs
blob747c8ab5f46401f56d552bc410785f90bade3d2c
1 // NAnt - A .NET build tool
2 // Copyright (C) 2001 Gerry Shaw
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // Gerry Shaw (gerry_shaw@yahoo.com)
20 namespace SourceForge.NAnt {
22 using System;
23 using System.IO;
25 [TaskName("exec")]
26 public class ExecTask : ExternalProgramBase {
28 [TaskAttribute("program", Required=true)]
29 string _program = null;
31 [TaskAttribute("commandline")]
32 string _commandline = null;
34 [TaskAttribute("basedir")]
35 string _baseDirectory = null;
37 // Stop the buildprocess if the command exits with a returncode other than 0.
38 [TaskAttribute("failonerror")]
39 [BooleanValidator()]
40 string _failonerror = Boolean.TrueString;
42 // TODO: change this to Int32Parameter to ensure value is a valid Int32 type after text expansion
43 [TaskAttribute("timeout")]
44 [Int32Validator()]
45 string _timeout = Int32.MaxValue.ToString();
47 public override string ProgramFileName { get { return Project.GetFullPath(_program); } }
48 public override string ProgramArguments { get { return _commandline; } }
49 public override string BaseDirectory { get { return Project.GetFullPath(_baseDirectory); } }
50 public override int TimeOut { get { return Convert.ToInt32(_timeout); } }
51 public override bool FailOnError { get { return Convert.ToBoolean(_failonerror); } }
53 protected override void ExecuteTask() {
54 Log.WriteLine(LogPrefix + "{0} {1}", Path.GetFileName(ProgramFileName), GetCommandLine());
55 base.ExecuteTask();