anchor.diff:  open System.IO.Compression
   open Paket
   open System.Text
  +open System.Text.RegularExpressions
   open System.Xml
   
   let nuspecId = "nuspec"
   let corePropsId = "coreProp"
   let contentTypePath = "[Content_Types].xml"
   
  -let contentTypeDoc fileList = 
  +let contentTypeDoc fileList =
       let declaration = XDeclaration("1.0", "UTF-8", "yes")
       let ns = XNamespace.Get "http://schemas.openxmlformats.org/package/2006/content-types"
       let root = XElement(ns + "Types")
  -    
  +
       let defaultNode extension contentType =
           let def = XElement(ns + "Default")
           def.SetAttributeValue(XName.Get "Extension", extension)
           def.SetAttributeValue(XName.Get "ContentType", contentType)
           def
  -    
  -    let knownExtensions = 
  +
  +    let knownExtensions =
           Map.ofList [ "rels", "application/vnd.openxmlformats-package.relationships+xml"
                        "psmdcp", "application/vnd.openxmlformats-package.core-properties+xml" ]
  -    
  +
       let ext path = Path.GetExtension(path).TrimStart([| '.' |]).ToLowerInvariant()
  -    
  -    let fType ext = 
  +
  +    let fType ext =
           knownExtensions
           |> Map.tryFind ext
  -        |> function 
  +        |> function
           | Some ft -> ft
           | None -> "application/octet"
  -    
  -    let contentTypes = 
  +
  +    let contentTypes =
           fileList
  -        |> Seq.choose (fun f -> 
  +        |> Seq.choose (fun f ->
                  let e = ext f
  -               if String.IsNullOrWhiteSpace e then 
  +               if String.IsNullOrWhiteSpace e then
                    None
                  else Some(e, fType e))
           |> Seq.distinct
           |> Seq.iter (fun (ex, ct) -> defaultNode ex ct |> root.Add)
  -    
  -    XDocument(declaration, box root)
  -
  -let nuspecDoc (info:CompleteInfo) = 
  +
  +    XDocument(declaration, box root)
  +
  +let nuspecDoc (info:CompleteInfo) =
       let core,optional = info
       let declaration = XDeclaration("1.0", "UTF-8", "yes")
       let ns = XNamespace.Get "http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd"
       let root = XElement(ns + "package")
  -    
  -    let addChildNode (parent : XElement) name value = 
  +
  +    let addChildNode (parent : XElement) name value =
           let node = XElement(ns + name)
           node.SetValue value
           parent.Add node
  -    
  +
       let metadataNode = XElement(ns + "metadata")
       root.Add metadataNode
       let (!!) = addChildNode metadataNode
  -    
  -    let (!!?) nodeName strOpt = 
  +
  +    let (!!?) nodeName strOpt =
           match strOpt with
           | Some s -> addChildNode metadataNode nodeName s
           | None -> ()
  -    
  -    let buildFrameworkReferencesNode libName = 
  +
  +    let buildFrameworkReferencesNode libName =
           let element = XElement(ns + "frameworkAssembly")
           element.SetAttributeValue(XName.Get "assemblyName", libName)
           element
  -    
  -    let buildFrameworkReferencesNode frameworkAssembliesList = 
  +
  +    let buildFrameworkReferencesNode frameworkAssembliesList =
           if frameworkAssembliesList = [] then () else
           let d = XElement(ns + "frameworkAssemblies")
           frameworkAssembliesList |> List.iter (buildFrameworkReferencesNode >> d.Add)
           metadataNode.Add d
   
  -    let buildDependencyNode (Id, (VersionRequirement(range, _))) = 
  +    let buildDependencyNode (Id, (VersionRequirement(range, _))) =
           let dep = XElement(ns + "dependency")
           dep.SetAttributeValue(XName.Get "id", Id)
   
  
positive.code:     r "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" ("/" + corePropsPath) corePropsId
      XDocument(declaration, box root)
  
  let xDocWriter (xDoc : XDocument) (stream : System.IO.Stream) = 
      let settings = new XmlWriterSettings(Indent = true, Encoding = Encoding.UTF8)
      use xmlWriter = XmlWriter.Create(stream, settings)
      xDoc.WriteTo xmlWriter
      xmlWriter.Flush()
  
  let writeNupkg  (core : CompleteCoreInfo) optional = 
      [ core.NuspecFileName, nuspecDoc(core,optional) |> xDocWriter
        corePropsPath, corePropsDoc core |> xDocWriter
        relsPath, relsDoc core |> xDocWriter ]
  
  let Write (core : CompleteCoreInfo) optional workingDir outputDir = 
      let outputPath = Path.Combine(outputDir, core.PackageFileName)
      if File.Exists outputPath then
          File.Delete outputPath
  
negative.code:         let source = Path.Combine(workingDir, fileName)
          if Directory.Exists source then
              addDir source targetFileName
          else
              if File.Exists source then
                  if not <| isExcluded source then
                      let fi = FileInfo(source)
                      let path = Path.Combine(targetFileName,fi.Name)
                      addEntryFromFile path source
              else
                  failwithf "Could not find source file %s" source
  
      // add metadata
      for path, writer in writeNupkg core optional do
          addEntry path writer
  
      entries
      |> Seq.toList
      |> contentTypeDoc
  