From 7f3b53bc0f0ba641468a870c8a66b64955862bb0 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Sun, 7 Dec 2014 12:30:28 +0100 Subject: [PATCH] Allow to remove nugets interactive - references #431 --- src/Paket.Core/RemoveProcess.fs | 53 +++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/src/Paket.Core/RemoveProcess.fs b/src/Paket.Core/RemoveProcess.fs index d2c5b1ded1..ed06f43078 100644 --- a/src/Paket.Core/RemoveProcess.fs +++ b/src/Paket.Core/RemoveProcess.fs @@ -21,33 +21,40 @@ let Remove(dependenciesFileName, package:PackageName, force, hard, interactive, let newLines = lines |> Seq.filter (fun l -> l.ToLower() <> name.ToLower()) File.WriteAllLines(fileName,newLines) - // check we have it removed from paket.references files - for project in allProjects do - let proj = FileInfo(project.FileName) - match ProjectFile.FindReferencesFile proj with - | None -> () - | Some fileName -> - let lines = File.ReadAllLines(fileName) - let installed = lines |> Seq.exists (fun l -> l.ToLower() = name.ToLower()) - if installed then - failwithf "%s is still installed in %s" name project.Name + // check we have it removed from all paket.references files + let stillInstalled = + allProjects + |> Seq.exists (fun project -> + let proj = FileInfo(project.FileName) + match ProjectFile.FindReferencesFile proj with + | None -> false + | Some fileName -> + let lines = File.ReadAllLines(fileName) + lines |> Seq.exists (fun l -> l.ToLower() = name.ToLower())) + + let oldLockFile = + let lockFileName = DependenciesFile.FindLockfile dependenciesFileName + LockFile.LoadFrom(lockFileName.FullName) - let exisitingDependenciesFile = DependenciesFile.ReadFromFile dependenciesFileName - let dependenciesFile = - exisitingDependenciesFile - .Remove(package) + let lockFile = + if stillInstalled then oldLockFile else + let exisitingDependenciesFile = DependenciesFile.ReadFromFile dependenciesFileName + let dependenciesFile = + exisitingDependenciesFile + .Remove(package) - let changed = exisitingDependenciesFile <> dependenciesFile - let lockFile = + let changed = exisitingDependenciesFile <> dependenciesFile + + if changed then + dependenciesFile.Save() + if changed then - UpdateProcess.updateWithModifiedDependenciesFile(true,dependenciesFile,package,force) + let lockFile = UpdateProcess.updateWithModifiedDependenciesFile(true,dependenciesFile,package,force) + lockFile.Save() + lockFile else - let lockFileName = DependenciesFile.FindLockfile dependenciesFileName - LockFile.LoadFrom(lockFileName.FullName) + oldLockFile if installAfter then let sources = DependenciesFile.ReadFromFile(dependenciesFileName).GetAllPackageSources() - InstallProcess.Install(sources, force, hard, lockFile) - - if changed then - dependenciesFile.Save() \ No newline at end of file + InstallProcess.Install(sources, force, hard, lockFile) \ No newline at end of file