Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to remove nugets interactive - references #431 #432

Merged
merged 1 commit into from
Dec 7, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 30 additions & 23 deletions src/Paket.Core/RemoveProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
InstallProcess.Install(sources, force, hard, lockFile)