Skip to content

Commit

Permalink
Don't create duplicate framework assembly references - fixes #297
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Oct 27, 2014
1 parent 96fea4c commit 035edbb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
35 changes: 23 additions & 12 deletions src/Paket.Core/ProjectFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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<_>()

Expand All @@ -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)
Expand Down
1 change: 0 additions & 1 deletion tests/Paket.Tests/InstallModel/Xml/ManualNodes.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
open Paket
open NUnit.Framework
open FsUnit
open System.Xml

[<Test>]
let ``should find custom nodes in doc``() =
Expand Down

0 comments on commit 035edbb

Please sign in to comment.