From f385e357bc85904ee6d2ebbdeafb28f914016619 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Tue, 10 Oct 2017 12:28:22 +0200 Subject: [PATCH 1/3] load scripts should only work on lock file - fixes #2372 --- src/Paket.Core/Installation/RestoreProcess.fs | 15 ++++++------- .../Installation/ScriptGeneration.fs | 21 +++++++++---------- .../PaketConfigFiles/DependenciesFile.fs | 15 +------------ .../PaketConfigFiles/DependencyCache.fs | 9 ++++---- src/Paket.Core/PaketConfigFiles/LockFile.fs | 13 ++++++++++++ 5 files changed, 36 insertions(+), 37 deletions(-) diff --git a/src/Paket.Core/Installation/RestoreProcess.fs b/src/Paket.Core/Installation/RestoreProcess.fs index 3d3468b562..bd333c4005 100644 --- a/src/Paket.Core/Installation/RestoreProcess.fs +++ b/src/Paket.Core/Installation/RestoreProcess.fs @@ -356,7 +356,7 @@ let createProjectReferencesFiles (lockFile:LockFile) (projectFile:ProjectFile) ( // it can happen that the references file doesn't exist if paket doesn't find one in that case we update the cache by deleting it. if paketCachedReferencesFileName.Exists then paketCachedReferencesFileName.Delete() -let CreateScriptsForGroups dependenciesFile lockFile (groups:Map) = +let CreateScriptsForGroups dependenciesFileName (lockFile:LockFile) (groups:Map) = let groupsToGenerate = groups |> Seq.map (fun kvp -> kvp.Value) @@ -365,12 +365,12 @@ let CreateScriptsForGroups dependenciesFile lockFile (groups:Map Seq.toList if not (List.isEmpty groupsToGenerate) then - let depsCache = DependencyCache(dependenciesFile,lockFile) - let dir = DirectoryInfo dependenciesFile.Directory + let depsCache = DependencyCache(dependenciesFileName,lockFile) + let rootPath = DirectoryInfo lockFile.RootPath let scripts = LoadingScripts.ScriptGeneration.constructScriptsFromData depsCache groupsToGenerate [] [] for sd in scripts do - sd.Save dir + sd.Save rootPath let FindOrCreateReferencesFile (projectFile:ProjectFile) = match projectFile.FindReferencesFile() with @@ -428,7 +428,6 @@ let Restore(dependenciesFileName,projectFile,force,group,referencesFileNames,ign if not (hasLocalFile || force) && isEarlyExit () then tracefn "Last restore is still up to date." else - let dependenciesFile = DependenciesFile.ReadFromFile(dependenciesFileName) if projectFile = None then extractRestoreTargets root |> ignore @@ -438,10 +437,12 @@ let Restore(dependenciesFileName,projectFile,force,group,referencesFileNames,ign s.Split([|';'|], StringSplitOptions.RemoveEmptyEntries) |> Array.map (fun s -> s.Trim()) |> Array.choose FrameworkDetection.Extract) + + + let dependenciesFile = DependenciesFile.ReadFromFile(dependenciesFileName) if not hasLocalFile && not ignoreChecks then let hasAnyChanges,nugetChanges,remoteFilechanges,hasChanges = DependencyChangeDetection.GetChanges(dependenciesFile,lockFile,false) - let checkResponse = if failOnChecks then failwithf else traceWarnfn if hasAnyChanges then checkResponse "paket.dependencies and paket.lock are out of sync in %s.%sPlease run 'paket install' or 'paket update' to recompute the paket.lock file." lockFileName.Directory.FullName Environment.NewLine @@ -532,6 +533,6 @@ let Restore(dependenciesFileName,projectFile,force,group,referencesFileNames,ign |> Async.RunSynchronously |> ignore - CreateScriptsForGroups dependenciesFile lockFile groups + CreateScriptsForGroups dependenciesFileName lockFile groups if isFullRestore then File.WriteAllText(restoreCacheFile, newContents))) \ No newline at end of file diff --git a/src/Paket.Core/Installation/ScriptGeneration.fs b/src/Paket.Core/Installation/ScriptGeneration.fs index 4635303c05..2e4cb13b48 100644 --- a/src/Paket.Core/Installation/ScriptGeneration.fs +++ b/src/Paket.Core/Installation/ScriptGeneration.fs @@ -127,13 +127,13 @@ module ScriptGeneration = self.Input |> Seq.map refString |> Seq.distinct |> String.concat "\n" /// Save the script in '/.paket/load/