anchor.diff:  open System.Collections.Generic
   
   type TargetTemplate<'a> =
  -  {Name: string;
  -   Dependencies: string list;
  -   Function : 'a -> unit}     
  +    { Name: string;
  +      Dependencies: string list;
  +      Function : 'a -> unit}
      
   type Target = TargetTemplate<unit>
      
   /// TargetDictionary  
   let TargetDict = new Dictionary<_,_>()
   
  -/// Final Targets 
  -/// Stores target and if it is activated
  +/// Final Targets - stores final target and if it is activated
   let FinalTargets = new Dictionary<_,_>()
   
   /// The executed targets
  
positive.code: 
  /// Gets a Target from the Target dictionary
  let getTarget x = 
    match TargetDict.TryGetValue x with
    | true, target -> target
    | _  -> failwithf "Target \"%s\" is not defined." x   
      
  /// Do nothing -  fun () -> ()   
  let DoNothing = (fun () -> ())
  
  /// Adds the dependency to the list of dependencies
  let dependency targetName dependentTargetName =
    let target,dependentTarget = getTarget targetName,getTarget dependentTargetName
    let rec checkDependencies dependentTarget =
      dependentTarget.Dependencies |> List.iter (fun dep ->
        if dep = targetName then 
          failwithf "Cyclic dependency between %s and %s" targetName dependentTarget.Name
        checkDependencies (getTarget dep))
        
    checkDependencies dependentTarget
      
    TargetDict.[targetName] <- 
      {target with 
         Dependencies = target.Dependencies @ [dependentTargetName]}
    
  /// Adds the dependencies to the list of dependencies  
  let Dependencies targetName = List.iter (dependency targetName)
  
negative.code: let Target name body = TargetTemplate body name ()  
  
  type BuildError(target, msg) =
      inherit System.Exception(sprintf "Stopped build! Error occured in target \"%s\".\r\nMessage: %s" target msg)
      member e.Target = target
      new (msg : string) = BuildError("[Unknown]", msg)
  
  let mutable errors = []   
  
  let targetError targetName msg =
      closeAllOpenTags()
      errors <- BuildError(targetName, msg) :: errors
      traceError <| sprintf "Running build failed.\nError:\n%s" msg
      sendTeamCityError msg        
   
  /// runs all activated final targets (in alphabetically order)
  let runFinalTargets() =
      FinalTargets
        |> Seq.filter (fun kv -> kv.Value)     // only if activated
        |> Seq.map (fun kv -> kv.Key)
        |> Seq.iter (fun name ->
             try             
                 tracefn "Starting Finaltarget: %s" name
                 TargetDict.[name].Function()
             with
             | exn -> targetError name exn.Message)                     
                
  let PrintDependencyGraph verbose target =
      logfn "%sDependencyGraph for Target %s:" (if verbose then String.Empty else "Shortened ") target 
      let printed = new HashSet<_>()
      let order = new List<_>()
      let rec printDependencies indent act =
          let target = TargetDict.[act]
          let addToOrder = not (printed.Contains act)
          printed.Add act |> ignore
      
          if addToOrder || verbose then log <| (sprintf "<== %s" act).PadLeft(3 * indent)
          target.Dependencies 
            |> Seq.iter (printDependencies (indent+1))
          if addToOrder then order.Add act
          
      printDependencies 0 target
      log ""
      log "The resulting target order is:"
      order |> Seq.iter (logfn " - %s")     
  
  /// Runs a Target and its dependencies        
  let run targetName =
      let rec runTarget targetName =
          try      
              if ExecutedTargets.Contains targetName || errors <> [] then () else
              let target = getTarget targetName    
              let dependencyString =
                  if target.Dependencies.IsEmpty then String.Empty else
                  sprintf "(==> %s)"
                    (target.Dependencies 
                      |> Seq.map (fun d -> (getTarget d).Name)
                      |> separated ", ")
        
              traceStartTarget target.Name dependencyString
        
              // run dependencies
              target.Dependencies |> List.iter runTarget
        
              if errors = [] then
                  target.Function()
                  ExecutedTargets.Add targetName |> ignore
                  traceEndTarget target.Name                
          with
          | exn -> targetError targetName exn.Message        
           
      try    
          PrintDependencyGraph false targetName
          runTarget targetName
      finally
          runFinalTargets()
          errors |> List.iter raise    
   
  /// Registers a final target (not activated)
  let FinalTarget name body = 
  