Skip to content

Commit

Permalink
- nuspec file
Browse files Browse the repository at this point in the history
if the attribute "version" is empty it will not be written.
- coreProp file
fixed creator element format
fixed version element value (removed "Some()")
  • Loading branch information
Виктор Борисов committed May 18, 2016
1 parent c5887c5 commit 0b149f6
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions src/Paket.Core/NupkgWriter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,15 @@ let nuspecDoc (info:CompleteInfo) =
let buildDependencyNode (Id, requirement:VersionRequirement) =
let dep = XElement(ns + "dependency")
dep.SetAttributeValue(XName.Get "id", Id)
dep.SetAttributeValue(XName.Get "version", requirement.FormatInNuGetSyntax())
let version = requirement.FormatInNuGetSyntax()
if String.IsNullOrEmpty version then () else
dep.SetAttributeValue(XName.Get "version", version)
dep

let buildDependenciesNode excludedDependencies dependencyList =
if List.isEmpty dependencyList then () else
let d = XElement(ns + "dependencies")
dependencyList
dependencyList
|> List.filter (fun d -> Set.contains (fst d) excludedDependencies |> not)
|> List.iter (buildDependencyNode >> d.Add)
metadataNode.Add d
Expand Down Expand Up @@ -150,10 +152,11 @@ let corePropsDoc (core : CompleteCoreInfo) =
let node = XElement(ns + name)
node.SetValue value
root.Add node
!! dc "creator" core.Authors

!! dc "creator" (core.Authors |> List.reduce (fun s1 s2 -> s1 + ", " + s2))
!! dc "description" core.Description
!! dc "identifier" core.Id
!! ns "version" core.Version
!! ns "version" core.Version.Value
XElement(ns + "keywords") |> root.Add
!! dc "title" core.Id
!! ns "lastModifiedBy" "paket"
Expand Down Expand Up @@ -239,31 +242,31 @@ let Write (core : CompleteCoreInfo) optional workingDir outputDir =
let problemChars = ["@","~~at~~"; "+","~~plus~~"]

let fakeEscapeProblemChars (source:string) =
problemChars
|> List.fold (fun (escaped:string) (problem, fakeEscape) ->
escaped.Replace(problem,fakeEscape)) source

let unFakeEscapeProblemChars (source:string) =
problemChars
|> List.fold (fun (escaped:string) (problem, fakeEscape) ->
escaped.Replace(fakeEscape, problem)) source

let escapeTarget (target:string) =
let escapedTargetParts =
target.Replace("\\", "/").Split('/')
problemChars
|> List.fold (fun (escaped:string) (problem, fakeEscape) ->
escaped.Replace(problem,fakeEscape)) source

let unFakeEscapeProblemChars (source:string) =
problemChars
|> List.fold (fun (escaped:string) (problem, fakeEscape) ->
escaped.Replace(fakeEscape, problem)) source

let escapeTarget (target:string) =
let escapedTargetParts =
target.Replace("\\", "/").Split('/')
|> Array.map Uri.EscapeDataString
String.Join("/" ,escapedTargetParts)

let toUri (escapedTarget:string) =
let toUri (escapedTarget:string) =
let uri1 = Uri(escapedTarget, UriKind.Relative)
let uri2 = Uri(uri1.GetComponents(UriComponents.SerializationInfoString, UriFormat.SafeUnescaped), UriKind.Relative)
uri2.GetComponents(UriComponents.SerializationInfoString, UriFormat.UriEscaped)

target
|> fakeEscapeProblemChars
|> fakeEscapeProblemChars
|> escapeTarget
|> unFakeEscapeProblemChars
|> toUri
|> toUri

let addEntry path writerF =
if entries.Contains(path) then () else
Expand All @@ -276,7 +279,7 @@ let Write (core : CompleteCoreInfo) optional workingDir outputDir =
let addEntryFromFile path source =
if entries.Contains(path) then () else
entries.Add path |> ignore

zipFile.CreateEntryFromFile(source,path) |> ignore

let ensureValidTargetName (target:string) =
Expand Down

0 comments on commit 0b149f6

Please sign in to comment.