From 468aa9c383623267f8702f98d141a1923a911556 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Mon, 5 Jan 2015 09:34:28 +0100 Subject: [PATCH] Paket update nuget X doesn't work - fixes #512 --- RELEASE_NOTES.md | 3 +++ paket.lock | 10 +++++----- src/Paket.Core/AddProcess.fs | 2 +- src/Paket.Core/DependencyChangeDetection.fs | 4 +--- src/Paket.Core/PublicAPI.fs | 2 +- src/Paket.Core/RemoveProcess.fs | 2 +- src/Paket.Core/UpdateProcess.fs | 18 ++++++++++++------ src/Paket/Paket.fsproj | 4 ++-- .../DependenciesFile/DependencyChangesSpecs.fs | 15 +++++++++------ 9 files changed, 35 insertions(+), 25 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index c9d9063d71..73dc312c09 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,6 @@ +#### 0.21.6 - 05.01.2015 +* BUGFIX: Paket update nuget X doesn't work - https://github.com/fsprojects/Paket/issues/512 + #### 0.21.5 - 03.01.2015 * Always trim line end in lockfile diff --git a/paket.lock b/paket.lock index 6138598a25..0f1ab0bb7f 100644 --- a/paket.lock +++ b/paket.lock @@ -2,10 +2,10 @@ NUGET remote: https://nuget.org/api/v2 specs: DotNetZip (1.9.3) - FAKE (3.12.2) + FAKE (3.13.1) FSharp.Compiler.Service (0.0.81) FSharp.Core (3.1.2.1) - FSharp.Formatting (2.4.38) + FSharp.Formatting (2.5.0) FSharp.Compiler.Service (>= 0.0.81) Microsoft.AspNet.Razor (2.0.30506) RazorEngine (3.3.0) @@ -20,8 +20,8 @@ NUGET NuGet.CommandLine (2.8.3) NUnit (2.6.4) NUnit.Runners (2.6.4) - Octokit (0.6.1) - Microsoft.Net.Http + Octokit (0.6.2) + Microsoft.Net.Http RazorEngine (3.3.0) Microsoft.AspNet.Razor (>= 2.0.30506.0) UnionArgParser (0.8.2) @@ -31,7 +31,7 @@ GITHUB FsUnit.fs (a8830b5a70e72a1948592cfa1e43e3c5b0a31b92) remote: fsharp/FAKE specs: - modules/Octokit/Octokit.fsx (875c384b04eb7cdee601b8c99852bba2d5e2142b) + modules/Octokit/Octokit.fsx (e24641b3214caf51154f0bfb12f639ebfdf68bdf) Octokit remote: nessos/Streams specs: diff --git a/src/Paket.Core/AddProcess.fs b/src/Paket.Core/AddProcess.fs index 5d914b267a..af2aa40809 100644 --- a/src/Paket.Core/AddProcess.fs +++ b/src/Paket.Core/AddProcess.fs @@ -13,7 +13,7 @@ let Add(dependenciesFileName, package, version, force, hard, interactive, instal dependenciesFile.Save() - let lockFile = UpdateProcess.SelectiveUpdate(dependenciesFile,force) + let lockFile = UpdateProcess.SelectiveUpdate(dependenciesFile,Some(NormalizedPackageName package),force) if interactive then for project in ProjectFile.FindAllProjects(Path.GetDirectoryName lockFile.FileName) do diff --git a/src/Paket.Core/DependencyChangeDetection.fs b/src/Paket.Core/DependencyChangeDetection.fs index 1f385dfb53..bb55180d9b 100644 --- a/src/Paket.Core/DependencyChangeDetection.fs +++ b/src/Paket.Core/DependencyChangeDetection.fs @@ -31,9 +31,7 @@ let findChangesInDependenciesFile(dependenciesFile:DependenciesFile,lockFile:Loc added |> Set.union modified -let PinUnchangedDependencies (dependenciesFile:DependenciesFile) (oldLockFile:LockFile) = - let changedDependencies = findChangesInDependenciesFile(dependenciesFile,oldLockFile) - +let PinUnchangedDependencies (dependenciesFile:DependenciesFile) (oldLockFile:LockFile) (changedDependencies:Set) = oldLockFile.ResolvedPackages |> Seq.map (fun kv -> kv.Value) |> Seq.filter (fun p -> not <| changedDependencies.Contains(NormalizedPackageName p.Name)) diff --git a/src/Paket.Core/PublicAPI.fs b/src/Paket.Core/PublicAPI.fs index 2c31d4bc01..8e5a948b37 100644 --- a/src/Paket.Core/PublicAPI.fs +++ b/src/Paket.Core/PublicAPI.fs @@ -97,7 +97,7 @@ type Dependencies(dependenciesFileName: string) = member this.Install(force: bool,hard: bool,withBindingRedirects:bool): unit = Utils.RunInLockedAccessMode( this.RootPath, - fun () -> UpdateProcess.SmartInstall(dependenciesFileName,force,hard,withBindingRedirects)) + fun () -> UpdateProcess.SmartInstall(dependenciesFileName,None,force,hard,withBindingRedirects)) /// Installs all dependencies. member this.Install(force: bool,hard: bool): unit = this.Install(force,hard,false) diff --git a/src/Paket.Core/RemoveProcess.fs b/src/Paket.Core/RemoveProcess.fs index c708ab0d1b..456f25ca01 100644 --- a/src/Paket.Core/RemoveProcess.fs +++ b/src/Paket.Core/RemoveProcess.fs @@ -45,7 +45,7 @@ let Remove(dependenciesFileName, package:PackageName, force, hard, interactive, dependenciesFile.Save() - UpdateProcess.SelectiveUpdate(dependenciesFile,force) + UpdateProcess.SelectiveUpdate(dependenciesFile,None,force) if installAfter then let sources = DependenciesFile.ReadFromFile(dependenciesFileName).GetAllPackageSources() diff --git a/src/Paket.Core/UpdateProcess.fs b/src/Paket.Core/UpdateProcess.fs index 4c93bda9da..15985fc9ce 100644 --- a/src/Paket.Core/UpdateProcess.fs +++ b/src/Paket.Core/UpdateProcess.fs @@ -39,7 +39,7 @@ let addPackagesFromReferenceFiles projects (dependenciesFile:DependenciesFile) = newDependenciesFile.Save() newDependenciesFile -let SelectiveUpdate(dependenciesFile:DependenciesFile, force) = +let SelectiveUpdate(dependenciesFile:DependenciesFile, exclude, force) = let lockFileName = DependenciesFile.FindLockfile dependenciesFile.FileName if not lockFileName.Exists then @@ -47,21 +47,27 @@ let SelectiveUpdate(dependenciesFile:DependenciesFile, force) = LockFile.Create(lockFileName.FullName, dependenciesFile.Options, resolution.ResolvedPackages, resolution.ResolvedSourceFiles) else let oldLockFile = LockFile.LoadFrom(lockFileName.FullName) + let changedDependencies = DependencyChangeDetection.findChangesInDependenciesFile(dependenciesFile,oldLockFile) - let dependenciesFile = DependencyChangeDetection.PinUnchangedDependencies dependenciesFile oldLockFile + let changed = + match exclude with + | None -> changedDependencies + | Some package -> Set.add package changedDependencies + + let dependenciesFile = DependencyChangeDetection.PinUnchangedDependencies dependenciesFile oldLockFile changed let resolution = dependenciesFile.Resolve(force) LockFile.Create(lockFileName.FullName, dependenciesFile.Options, resolution.ResolvedPackages, oldLockFile.SourceFiles) /// Smart install command -let SmartInstall(dependenciesFileName, force, hard, withBindingRedirects) = +let SmartInstall(dependenciesFileName, exclude, force, hard, withBindingRedirects) = let root = Path.GetDirectoryName dependenciesFileName let projects = InstallProcess.findAllReferencesFiles(root) let dependenciesFile = DependenciesFile.ReadFromFile(dependenciesFileName) |> addPackagesFromReferenceFiles projects - let lockFile = SelectiveUpdate(dependenciesFile,force) + let lockFile = SelectiveUpdate(dependenciesFile,exclude,force) InstallProcess.InstallIntoProjects( dependenciesFile.GetAllPackageSources(), @@ -80,7 +86,7 @@ let UpdatePackage(dependenciesFileName, packageName : PackageName, newVersion, f .Save() | None -> () - SmartInstall(dependenciesFileName,force,hard,withBindingRedirects) + SmartInstall(dependenciesFileName,Some(NormalizedPackageName packageName),force,hard,withBindingRedirects) /// Update command let Update(dependenciesFileName, force, hard, withBindingRedirects) = @@ -88,4 +94,4 @@ let Update(dependenciesFileName, force, hard, withBindingRedirects) = if lockFileName.Exists then lockFileName.Delete() - SmartInstall(dependenciesFileName,force,hard,withBindingRedirects) \ No newline at end of file + SmartInstall(dependenciesFileName,None,force,hard,withBindingRedirects) \ No newline at end of file diff --git a/src/Paket/Paket.fsproj b/src/Paket/Paket.fsproj index 8c1966c894..c9acd38a61 100644 --- a/src/Paket/Paket.fsproj +++ b/src/Paket/Paket.fsproj @@ -28,12 +28,12 @@ update -f - install --log-file "C:\temp\log.txt" + update nuget JsonLd.Entities Project paket.exe - c:\code\paketkopie + d:\code\paketkopie pdbonly diff --git a/tests/Paket.Tests/DependenciesFile/DependencyChangesSpecs.fs b/tests/Paket.Tests/DependenciesFile/DependencyChangesSpecs.fs index 6255b144f5..dddb244266 100644 --- a/tests/Paket.Tests/DependenciesFile/DependencyChangesSpecs.fs +++ b/tests/Paket.Tests/DependenciesFile/DependencyChangesSpecs.fs @@ -35,7 +35,8 @@ nuget Castle.Windsor-log4net""" let cfg = DependenciesFile.FromCode(after) let lockFile = LockFile.Parse("",toLines lockFileData) - let newDependencies = DependencyChangeDetection.PinUnchangedDependencies cfg lockFile + let changedDependencies = DependencyChangeDetection.findChangesInDependenciesFile(cfg,lockFile) + let newDependencies = DependencyChangeDetection.PinUnchangedDependencies cfg lockFile changedDependencies newDependencies.DirectDependencies |> shouldEqual Map.empty @@ -70,8 +71,9 @@ nuget NUnit""" let cfg = DependenciesFile.FromCode(after) let lockFile = LockFile.Parse("",toLines lockFileData) + let changedDependencies = DependencyChangeDetection.findChangesInDependenciesFile(cfg,lockFile) - let newDependencies = DependencyChangeDetection.PinUnchangedDependencies cfg lockFile + let newDependencies = DependencyChangeDetection.PinUnchangedDependencies cfg lockFile changedDependencies let expected = Map.ofList ([(PackageName "Castle.Core", VersionRequirement (Specific(SemVer.Parse "3.3.3"),No)); @@ -116,8 +118,9 @@ nuget Castle.Windsor-log4net >= 3.3.0""" let cfg = DependenciesFile.FromCode(after) let lockFile = LockFile.Parse("",toLines lockFileData) + let changedDependencies = DependencyChangeDetection.findChangesInDependenciesFile(cfg,lockFile) - let newDependencies = DependencyChangeDetection.PinUnchangedDependencies cfg lockFile + let newDependencies = DependencyChangeDetection.PinUnchangedDependencies cfg lockFile changedDependencies let expected = Map.ofList ([(PackageName "Castle.Core", VersionRequirement (Specific(SemVer.Parse "3.3.3"),No)); @@ -161,13 +164,13 @@ nuget Castle.Windsor-log4net >= 3.4.0""" let cfg = DependenciesFile.FromCode(after) let lockFile = LockFile.Parse("",toLines lockFileData) + let changedDependencies = DependencyChangeDetection.findChangesInDependenciesFile(cfg,lockFile) - let newDependencies = DependencyChangeDetection.PinUnchangedDependencies cfg lockFile + let newDependencies = DependencyChangeDetection.PinUnchangedDependencies cfg lockFile changedDependencies let expected = Map.ofList ([(PackageName "Castle.Windsor-log4net", VersionRequirement (Minimum(SemVer.Parse "3.4.0"),No));]) newDependencies.DirectDependencies - |> shouldEqual expected - + |> shouldEqual expected \ No newline at end of file