Example #1
0
        /// <summary>
        /// Executes the specified task.
        /// </summary>
        protected override void ExecuteTask()
        {
            Target           owningTarget = Parent as Target;
            StringCollection dependencies = _dependencies;

            foreach (string target in dependencies)
            {
                // check to see if one of the targets we are going execute includes the current target.
                // if so, throw
                if (owningTarget != null)
                {
                    if (owningTarget.Name == target)
                    {
                        throw new BuildException("Depends task cannot depend on its own parent.", Location);
                    }

                    // topologically sorted list of targets that will be executed
                    TargetCollection targets = Project.TopologicalTargetSort(target, Project.Targets);

                    // check if owning target is part of list of targets that will be executed again
                    if (targets.Find(owningTarget.Name) != null)
                    {
                        // check if owning target is actually a dependency of the target that should be executed
                        if (targets.IndexOf(targets.Find(owningTarget.Name)) < targets.IndexOf(targets.Find(target)))
                        {
                            throw new BuildException("Circular dependency: " + targets.ToString(" <- ") + " <- " + owningTarget.Name);
                        }
                    }
                }

                Project.Execute(target, false);
            }
        }
Example #2
0
        /// <summary>
        /// Executes the specified target.
        /// </summary>
        protected override void ExecuteTask()
        {
            Target owningTarget = Parent as Target;

            if (owningTarget != null)
            {
                // topologically sorted list of targets that will be executed
                TargetCollection targets = Project.TopologicalTargetSort(TargetName, Project.Targets);

                // check if owning target is part of list of targets that will
                // be executed again
                if (targets.Find(owningTarget.Name) != null)
                {
                    // check if owning target is actually a dependency of the
                    // target that should be executed
                    if (targets.IndexOf(targets.Find(owningTarget.Name)) < targets.IndexOf(targets.Find(TargetName)))
                    {
                        throw new BuildException("Circular dependency: " + targets.ToString(" <- ") + " <- " + owningTarget.Name);
                    }
                }
            }

            try
            {
                Project.Execute(TargetName, CascadeDependencies, this, this.CallStack, this.Logger, this.arguments);
            }
            catch (ArgumentException e)
            {
                throw new BuildException(e.Message, this.Location);
            }
        }