diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 82f9766bdf..573d50044e 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,6 @@ +#### 0.38.1 - 31.03.2015 +* Added frameworkAssemblies to nuspec templating - https://github.com/fsprojects/Paket/issues/740 + #### 0.38.0 - 30.03.2015 * The restore process downloads package licenses automatically - https://github.com/fsprojects/Paket/pull/737 diff --git a/docs/content/template-files.md b/docs/content/template-files.md index 9c0649239c..e9efc54abe 100644 --- a/docs/content/template-files.md +++ b/docs/content/template-files.md @@ -116,6 +116,17 @@ A references block looks like this: If you omit the references block then all libraries in the packages will get referenced. +#### Framework assembly references + +A block with framework assembly references looks like this: + + [lang=batchfile] + frameworkAssemblies + System.Xml + System.Xml.Linq + +If you omit the references block then all libraries in the packages will get referenced. + #### Dependencies A dependency block looks like this: diff --git a/src/Paket.Core/NupkgWriter.fs b/src/Paket.Core/NupkgWriter.fs index 9822950dbd..e2663062f2 100644 --- a/src/Paket.Core/NupkgWriter.fs +++ b/src/Paket.Core/NupkgWriter.fs @@ -66,6 +66,18 @@ let nuspecDoc (info:CompleteInfo) = | Some s -> addChildNode metadataNode nodeName s | None -> () + let buildFrameworkReferencesNode libName = + let element = XElement(ns + "frameworkAssembly") + element.SetAttributeValue(XName.Get "assemblyName", libName) + element.SetAttributeValue(XName.Get "targetFramework", "") + element + + 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 dep = XElement(ns + "dependency") dep.SetAttributeValue(XName.Get "id", Id) @@ -114,6 +126,7 @@ let nuspecDoc (info:CompleteInfo) = !! "developmentDependency" "true" optional.References |> buildReferencesNode + optional.FrameworkAssemblyReferences |> buildFrameworkReferencesNode optional.Dependencies |> buildDependenciesNode XDocument(declaration, box root) diff --git a/src/Paket.Core/TemplateFile.fs b/src/Paket.Core/TemplateFile.fs index 7ff751bae3..a218aed6d8 100644 --- a/src/Paket.Core/TemplateFile.fs +++ b/src/Paket.Core/TemplateFile.fs @@ -119,6 +119,7 @@ type internal OptionalPackagingInfo = DevelopmentDependency : bool Dependencies : (string * VersionRequirement) list References : string list + FrameworkAssemblyReferences : string list Files : (string * string) list } static member Epmty : OptionalPackagingInfo = { Title = None @@ -135,6 +136,7 @@ type internal OptionalPackagingInfo = DevelopmentDependency = false Dependencies = [] References = [] + FrameworkAssemblyReferences = [] Files = [] } type internal CompleteInfo = CompleteCoreInfo * OptionalPackagingInfo @@ -231,6 +233,13 @@ module internal TemplateFile = |> Option.map (fun d -> d.Split '\n') |> Option.map List.ofSeq |> fun x -> defaultArg x [] + + + let private getFrameworkReferences (map : Map) = + Map.tryFind "frameworkassemblies" map + |> Option.map (fun d -> d.Split '\n') + |> Option.map List.ofSeq + |> fun x -> defaultArg x [] let private getOptionalInfo (map : Map) = let get (n : string) = Map.tryFind (n.ToLowerInvariant()) map @@ -284,6 +293,7 @@ module internal TemplateFile = DevelopmentDependency = developmentDependency Dependencies = getDependencies map References = getReferences map + FrameworkAssemblyReferences = getFrameworkReferences map Files = getFiles map } let Parse(file,contentStream : Stream) = diff --git a/src/Paket/Paket.fsproj b/src/Paket/Paket.fsproj index f7bc36dd4c..4e7e67cf32 100644 --- a/src/Paket/Paket.fsproj +++ b/src/Paket/Paket.fsproj @@ -27,10 +27,10 @@ 3 - restore -f + install Project paket.exe - D:\code\Paketkopie + D:\code\PaketKopie pdbonly diff --git a/tests/Paket.Tests/NuspecWriterSpecs.fs b/tests/Paket.Tests/NuspecWriterSpecs.fs index 5c344d1d6a..967b209d18 100644 --- a/tests/Paket.Tests/NuspecWriterSpecs.fs +++ b/tests/Paket.Tests/NuspecWriterSpecs.fs @@ -63,6 +63,40 @@ let ``should serialize dependencies``() = |> normalizeLineEndings |> shouldEqual (normalizeLineEndings result) + +[] +let ``should serialize frameworkAssemblues``() = + let result = """ + + Paket.Tests + 1.0.0.0 + Two, Authors + A description + f# rules + + + + + +""" + + let core = + { Id = "Paket.Tests" + Version = SemVer.Parse "1.0.0.0" |> Some + Authors = [ "Two"; "Authors" ] + Description = "A description" } + + let optional = + { OptionalPackagingInfo.Epmty with + Tags = [ "f#"; "rules" ] + FrameworkAssemblyReferences = + [ "System.Xml"; "System.Xml.Linq" ] } + + let doc = NupkgWriter.nuspecDoc (core, optional) + doc.ToString() + |> normalizeLineEndings + |> shouldEqual (normalizeLineEndings result) + [] let ``should not serialize files``() = let result = """ diff --git a/tests/Paket.Tests/TemplateFileParsing.fs b/tests/Paket.Tests/TemplateFileParsing.fs index 7b407835ae..09690d38d6 100644 --- a/tests/Paket.Tests/TemplateFileParsing.fs +++ b/tests/Paket.Tests/TemplateFileParsing.fs @@ -275,6 +275,34 @@ version reference2 |> shouldEqual "someOtherFile.dll" | _ -> Assert.Fail() + +[] +let ``Detect framework references correctly``() = + let text = """type file +id My.Thing +authors Bob McBob +description + A longer description + on two lines. +frameworkAssemblies + somefile + someOtherFile.dll +version + 1.0 +""" + let sut = + TemplateFile.Parse("file1.template", strToStream text) + |> returnOrFail + |> function + | CompleteInfo (_, opt) + | ProjectInfo (_, opt) -> opt + + match sut.FrameworkAssemblyReferences with + | reference1::reference2::[] -> + reference1 |> shouldEqual "somefile" + reference2 |> shouldEqual "someOtherFile.dll" + | _ -> Assert.Fail() + [] let ``Detect multiple files correctly``() = let text = """type file