I was also asking about looping functionality fairly recently, for
fairly similar reasons. Whilst some of the other replies to your
question may have provided a more suitable approach to your particular
problem, I thought it was worthwhile pointing out how I ended up solving
the general looping problem, using a custom script task:
 
<script language="C#">
    <code><![CDATA[
        public static void ScriptMain(Project project) {
            while (expression) {
                project.Execute("some-target");
            }
        }
    ]]></code>
</script>
 
This reapeatedly invokes the 'some-target' target whilst 'expression'
evaluates to true. I had looked into creating a while and dowhile task.
This initially looked fairly straightforward to do, but I soon ran into
problems persuading NAnt to reevaluate the condition each time through
the loop rather than just once up-front. As I had a looming deadline
approaching, and the script works, I never got round to implementing a
while and dowhile task, sadly.
 
I hope this proves helpful for someone.
 
Chris

 
________________________________

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Michael
Frederick
Sent: 15 November 2006 17:51
To: nant-users@lists.sourceforge.net
Subject: [NAnt-users] Does NAnt have a "while" capability?


I need a NAnt project to do some work and then wait for some event to
occur, such as a specific file in a specific directory to appear.  To do
this I will need some sort of "while (file-exists != "true")"
capability.  This means I would need 2 capabilities; a "sleep" taks
(which is present) and a looping construct.  Are there *any* looping
constructs in NAnt?
 
Let me explain what I am trying to do.  I have a CruiseControl.NET
project which does a <forceBuild> on three other CCNet projects that run
in parallel.  I need something on the back end which waits until all 3
worker projects have completed and then continues on with more build
steps.  I'm not concerned with contention here; the projects literally
running in parallel are not a performance issue.  So I have:
 
Startup project -> does a <forceBuild> on 3 worker projects -> BackEnd
project waits on all 3 worker projects to complete and does more work.
 
I had been looking into having the BackEnd project use CCNet for the
sync, but due to limitations there I cannot do this (the worker projects
may finish hours apart).  So I changed the above scheme to be:
 
Startup project -> does a <forceBuild> on 3 worker projects.  1 of the
worker projects ends by doing a <forceBuild> on the BackEnd project ->
BackEnd project runs a NAnt task which waits for the other 2 worker
projects to complete and then does more work.
 
I am attempting to write a NAnt project which does a type of multiple
project synchronization.  It seems like I have seen in this list some
references on how to do this, but a quick search of the archives found
nothing.  Any help would be appreciated.
 
--
Mike Frederick
Software Developer
[EMAIL PROTECTED]
 
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to