Why not just use windows scheduler to run the .build every 20 minutes or
whatever. This is actually what we are doing now (poor mans continuous
integration). Although we are working on setting up CC.Net to do this
correctly.

BOb


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Chris
Lambrou
Sent: Friday, October 13, 2006 3:39 AM
To: Peter Lanoie
Cc: nant-users@lists.sourceforge.net
Subject: Re: [NAnt-users] Conditional looping within a NAnt script (is
therea while' task?)

Peter,

Thanks for replying. One of the reasons I wanted a looping task was that
I wanted to repeat the execution of a continuous build process until a
fixed time (say 8 o'clock in the evening). In the end, I resorted to
using a custom script task as follows:

        <script language="C#">
            <code><![CDATA[
            public static void ScriptMain(Project project) {
                do {
                    project.Execute("continuous-repeat-body");
                } while (DateTime.Now.Hour < 20);
            }
            ]]></code>
        </script>

It would have been much nicer to have a dowhile (or while) task, like
this:

        <dowhile test="${datetime::get-hour(datetime::now()) < 20}">
            <call target="continuous-repeat-body"/>
        </script>


To be honest, once I had the script working, I had other more pressing
matters to attend to, so haven't really returned to the problem of
implementing a looping task. I hope to return to the script at some
point in the next few weeks, so if you're about to have a go at
implementing a looping task shortly, I'd be very pleased to know how it
turns out.

I think it would be far more useful to be able to specify an expression
for the loop condition, rather than a simple property. Especially for a
while task, where you don't want to have to execute the body of the task
in order to define the condition property (thus making the task a
dowhile task). Of course, we could resort to something along the
following lines, where the <pretest/> section is executed immediately
before the evaluation of the test condition:

        <while test="loop-condition">
            <pretest>
                ...
                [tasks required to determine the loop condition]
                ...
                <property name="loop-condition"
value="[some_expression]"/>
            </pretest>
            <do>
                ...
                [main loop body]
                ...
            </do>
        </while>

A <dowhile/> task would have the same syntax, but the <pretest/> section
would be evaluated after the <do/> section. This is beginning to
approach the clumsyness of my original <script/> task workaround, but I
can see how it would be useful if evaluating the loop condition required
some complex operation that couldn't be carried out by a single
expression alone. I found that the tricky part was being able to assign
an expression to the task attribute and not have it evaluated
immediately (like a property) but have the evaluation deferred until the
task body executes, so that it can be repeatedly evaluated as part of
the loop condition.

Nant's built in expression syntax makes it far more like a real, useful
scripting language than Ant (expressions defined using XML logic and
condition elements is just painful to use and is very inflexible), but I
think it's a shame that looping constructs aren't available in either
NAnt or NAntContrib - ah well...

Chris


P.S.  More random thoughts entering my head - how about a <break/> or a
<continue/> task directive that can be embedded in the loop body?




-----Original Message-----
From: Peter Lanoie [mailto:[EMAIL PROTECTED] 
Sent: 12 October 2006 22:17
To: Chris Lambrou
Subject: [NAnt-users] Conditional looping within a NAnt script (is there
a while' task?)

Chris,

Don't know if you ever solved this or not, but I was looking for the
same thing.

I think what you would want to do is change it so that instead of
deriving from the IF task and using its "ConditionsTrue" variable you
should derive from TaskContainer.  Then add a property name as the
property to test each time the while loops.  The ExecuteTask code can
check that property value internally so it always gets fresh data.

<while property="myWhileLoopTestProp">
        ...[other tasks]...
</while>

private string _strProp;

[TaskAttribute("property", Required=true)] public string Property {
        get { return _strProp; }
        set {
                _strProp = value;
                if (Properties.IsReadOnlyProperty(_strProp)) {
                        throw new BuildException("Property is readonly!
:" + _strProp, Location);
                }
        }
}

[TaskName("while")]
public class WhileTask : TaskContainer {
    protected override void ExecuteTask() {
        //while test will continually test the live value of the
property
        while (Properties[_strProp]) {
            base.ExecuteTask();
        }
    }
}

I'll venture a guess that 'ConditionsTrue' might be something you'd want
to put an expression into instead of just a property value. In that case
you can still use what I suggested, you just have to put the expression
in the value attribute of a standard property tag inside the while tasks
inner tasks.

<while property="myWhileLoopTestProp">
        ...[other tasks]...
        <property name="myWhileLoopTestProp" value="[nant expression to
set property]" /> </while>



Let me know what you ended up doing or if this works for you.  I'm going
to be implementing it tomorrow myself.

Peter


------------------------------------------------------------------------
-
Using Tomcat but need to do more? Need to support web services,
security?
Get stuff done quickly with pre-integrated technology to make your job
easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache
Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to