+
+ List <Target> GetDependencies ()
+ {
+ List <Target> list = new List <Target> ();
+ Target t;
+ string [] targetNames;
+ Expression deps;
+
+ if (DependsOnTargets != String.Empty) {
+ deps = new Expression ();
+ deps.Parse (DependsOnTargets, true);
+ targetNames = (string []) deps.ConvertTo (Project, typeof (string []));
+ foreach (string name in targetNames) {
+ t = project.Targets [name.Trim ()];
+ if (t == null)
+ throw new InvalidProjectFileException (String.Format ("Target '{0}' not found.", name.Trim ()));
+ list.Add (t);
+ }
+ }
+ return list;
+ }
+
+ bool BuildDependencies (List <Target> deps)
+ {
+ foreach (Target t in deps) {
+ if (t.BuildState == BuildState.NotStarted)
+ if (!t.Build ())
+ return false;
+ if (t.BuildState == BuildState.Started)
+ throw new InvalidProjectFileException ("Cycle in target dependencies detected");
+ }
+
+ return true;
+ }