Skip to content

Commit

Permalink
Restored uninstall functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
colinbull committed Mar 25, 2015
1 parent 046432f commit 87f031e
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/Paket.Core/ProjectFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,19 @@ type ProjectFile =
| None ->
let firstNode = fileItemsInSameDir |> Seq.head
firstNode.ParentNode.InsertBefore(libReferenceNode, firstNode) |> ignore

let paketNodes =
this.FindPaketNodes("Compile")
@ this.FindPaketNodes("Content")

//remove uneeded files
for paketNode in paketNodes do
match getAttribute "Include" paketNode with
| Some path ->
if not(fileItems |> List.exists (fun fi -> fi.Include = path))
then paketNode.ParentNode.RemoveChild(paketNode) |> ignore
else ()
| _ -> ()

this.DeleteIfEmpty("PropertyGroup")
this.DeleteIfEmpty("ItemGroup")
Expand Down
2 changes: 1 addition & 1 deletion src/Paket/Paket.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<StartArguments>update</StartArguments>
<StartAction>Project</StartAction>
<StartProgram>paket.exe</StartProgram>
<StartWorkingDirectory>c:\code\Paket09x</StartWorkingDirectory>
<StartWorkingDirectory>D:\Appdev\officeprovider\</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand Down
36 changes: 36 additions & 0 deletions tests/Paket.Tests/ProjectFile/OutputSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,40 @@ let ``should maintain order when updating project file items`` () =
"WordProvider.fs"
"ProviderEntryPoint.fs"
]
CollectionAssert.AreEqual(expected, actual)

[<Test>]
let ``should remove missing files that exist in the project`` () =

let projFile = ProjectFile.Load("./ProjectFile/TestData/MaintainsOrdering.fsprojtest").Value
let fileItems = [
{ BuildAction = "Compile"; Include = "DebugProvidedTypes.fs"; Link = None }
{ BuildAction = "Compile"; Include = "ProvidedTypes.fs"; Link = None }
{ BuildAction = "Content"; Include = "ProvidedTypes.fsi"; Link = None }
]
projFile.UpdateFileItems(fileItems, false)

let rec nodes node =
seq {
for node in node |> Seq.cast<XmlNode> do
if node.Name = "Compile" || node.Name = "Content"
then yield Paket.Xml.getAttribute "Include" node
yield! nodes node
}

let actual =
nodes projFile.Document
|> Seq.choose id
|> Seq.toList
let expected =
[
"ProvidedTypes.fsi"
"ProvidedTypes.fs"
"DebugProvidedTypes.fs"
"QuotationHelpers.fs"
"CommonTypes.fs"
"ExcelProvider.fs"
"WordProvider.fs"
"ProviderEntryPoint.fs"
]
CollectionAssert.AreEqual(expected, actual)

1 comment on commit 87f031e

@colinbull
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this do the trick?

Please sign in to comment.