diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index bf0884a652..a067a7df22 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,6 @@ +#### 0.10.1 - 27.10.2014 +* Don't create duplicate framework assembly references - https://github.com/fsprojects/Paket/issues/297 + #### 0.10.0 - 24.10.2014 * Initial version of `paket remove` command - http://fsprojects.github.io/Paket/paket-remove.html * Paket add doesn't fail on second attempt - https://github.com/fsprojects/Paket/issues/295 diff --git a/src/Paket.Core/ProjectFile.fs b/src/Paket.Core/ProjectFile.fs index 87dd57ce60..14236e242d 100644 --- a/src/Paket.Core/ProjectFile.fs +++ b/src/Paket.Core/ProjectFile.fs @@ -142,6 +142,14 @@ type ProjectFile = !hasCustom + member this.HasFrameworkAssemblyNode(assemblyName) = + let found = ref false + for node in this.Document.SelectNodes("//ns:Reference", this.Namespaces) do + if node.Attributes.["Include"].InnerText.Split(',').[0] = assemblyName then + found := true + + !found + member this.DeleteCustomNodes(model:InstallModel) = let nodesToDelete = List<_>() @@ -161,22 +169,25 @@ type ProjectFile = let itemGroup = createNode(this.Document,"ItemGroup") for lib in references do - let reference = - match lib with - | Reference.Library lib -> - let fi = new FileInfo(normalizePath lib) + match lib with + | Reference.Library lib -> + let fi = new FileInfo(normalizePath lib) - createNode(this.Document,"Reference") - |> addAttribute "Include" (fi.Name.Replace(fi.Extension,"")) - |> addChild (createNodeWithText(this.Document,"HintPath",createRelativePath this.FileName fi.FullName)) - |> addChild (createNodeWithText(this.Document,"Private","True")) - |> addChild (createNodeWithText(this.Document,"Paket","True")) - | Reference.FrameworkAssemblyReference frameworkAssembly -> + createNode(this.Document,"Reference") + |> addAttribute "Include" (fi.Name.Replace(fi.Extension,"")) + |> addChild (createNodeWithText(this.Document,"HintPath",createRelativePath this.FileName fi.FullName)) + |> addChild (createNodeWithText(this.Document,"Private","True")) + |> addChild (createNodeWithText(this.Document,"Paket","True")) + |> itemGroup.AppendChild + |> ignore + | Reference.FrameworkAssemblyReference frameworkAssembly -> + if not <| this.HasFrameworkAssemblyNode(frameworkAssembly) then createNode(this.Document,"Reference") |> addAttribute "Include" frameworkAssembly |> addChild (createNodeWithText(this.Document,"Paket","True")) - - itemGroup.AppendChild(reference) |> ignore + |> itemGroup.AppendChild + |> ignore + itemGroup let groupChooseNode = this.Document.CreateElement("Choose", Constants.ProjectDefaultNameSpace) diff --git a/tests/Paket.Tests/InstallModel/Xml/ManualNodes.fs b/tests/Paket.Tests/InstallModel/Xml/ManualNodes.fs index 8c9fa98272..d3ee6e1f55 100644 --- a/tests/Paket.Tests/InstallModel/Xml/ManualNodes.fs +++ b/tests/Paket.Tests/InstallModel/Xml/ManualNodes.fs @@ -3,7 +3,6 @@ open Paket open NUnit.Framework open FsUnit -open System.Xml [] let ``should find custom nodes in doc``() =