From c1610747ef1cb2ea6a8b58321585c1fd9b321fad Mon Sep 17 00:00:00 2001 From: Lukas Rieger Date: Mon, 24 Apr 2017 00:50:33 +0200 Subject: [PATCH] fix https://github.com/fsprojects/Paket/issues/2263 use group framework restrictions to decide if a package is global or fw-specific --- src/Paket.Core/Files/ProjectFile.fs | 8 ++++---- src/Paket.Core/InstallProcess.fs | 30 +++++++++++++++++++---------- src/Paket.Core/Utils.fs | 4 ++++ 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/Paket.Core/Files/ProjectFile.fs b/src/Paket.Core/Files/ProjectFile.fs index 52fc0458c1..f2206b0a27 100644 --- a/src/Paket.Core/Files/ProjectFile.fs +++ b/src/Paket.Core/Files/ProjectFile.fs @@ -1013,7 +1013,7 @@ module ProjectFile = let updateReferences rootPath - (completeModel: Map) + (completeModel: Map) (directPackages : Map) (usedPackages : Map) (project:ProjectFile) = @@ -1053,12 +1053,12 @@ module ProjectFile = |> Seq.filter (fun kv -> usedPackages.ContainsKey kv.Key) |> Seq.sortBy (fun kv -> let group, packName = kv.Key in group.GetCompareString(), packName.GetCompareString()) |> Seq.map (fun kv -> - deleteCustomModelNodes (snd kv.Value) project + deleteCustomModelNodes (sndOf3 kv.Value) project let installSettings = snd usedPackages.[kv.Key] let restrictionList = installSettings.FrameworkRestrictions |> getRestrictionList let projectModel = - (snd kv.Value) + (sndOf3 kv.Value) .ApplyFrameworkRestrictions(restrictionList) .FilterExcludes(installSettings.Excludes) .RemoveIfCompletelyEmpty() @@ -1079,7 +1079,7 @@ module ProjectFile = let importTargets = defaultArg installSettings.ImportTargets true - let allFrameworks = applyRestrictionsToTargets restrictionList KnownTargetProfiles.AllProfiles + let allFrameworks = applyRestrictionsToTargets ((thirdOf3 kv.Value)) KnownTargetProfiles.AllProfiles generateXml projectModel usedFrameworkLibs installSettings.Aliases installSettings.CopyLocal importTargets installSettings.ReferenceCondition (set allFrameworks) project) |> Seq.iter (fun ctx -> for chooseNode in ctx.ChooseNodes do diff --git a/src/Paket.Core/InstallProcess.fs b/src/Paket.Core/InstallProcess.fs index a1beb9d7a1..c637e53722 100644 --- a/src/Paket.Core/InstallProcess.fs +++ b/src/Paket.Core/InstallProcess.fs @@ -13,6 +13,8 @@ open Paket.PackageSources open Paket.PackagesConfigFile open Paket.Requirements open System.Collections.Generic +open Paket.ProjectFile +open System.Diagnostics let updatePackagesConfigFile (model: Map) packagesConfigFileName = let packagesInConfigFile = PackagesConfigFile.Read packagesConfigFileName @@ -176,13 +178,21 @@ let CreateModel(alternativeProjectRoot, root, force, dependenciesFile:Dependenci RemoteDownload.DownloadSourceFiles(root, kv.Key, force, files) lockFile.Groups - |> Seq.map (fun kv' -> - let sources = dependenciesFile.Groups.[kv'.Key].Sources - let caches = dependenciesFile.Groups.[kv'.Key].Caches - kv'.Value.Resolution - |> Map.filter (fun name _ -> packages.Contains(kv'.Key,name)) - |> Seq.map (fun kv -> CreateInstallModel(alternativeProjectRoot, root,kv'.Key,sources,caches,force,kv.Value)) - |> Seq.toArray + |> Seq.map (fun kv' -> + let groupName, lockFileGroup = kv'.Key, kv'.Value + let depFileGroup = dependenciesFile.Groups.[groupName] + let sources = depFileGroup.Sources + let caches = depFileGroup.Caches + let depFileGroupRestrictions = depFileGroup.Options.Settings.FrameworkRestrictions + let lockFileGroupRestrictions = lockFileGroup.Options.Settings.FrameworkRestrictions + [| for kv in lockFileGroup.Resolution do + let packageName, resolvedPackage = kv.Key, kv.Value + if packages.Contains(groupName,packageName) then + yield async { + let! (groupName,packageName), (package,model) = CreateInstallModel(alternativeProjectRoot, root,groupName,sources,caches,force,resolvedPackage) + return (groupName,packageName), (package,model, getRestrictionList depFileGroupRestrictions) + } + |] |> Async.Parallel |> Async.RunSynchronously) |> Seq.concat @@ -347,7 +357,7 @@ let InstallIntoProjects(options : InstallerOptions, forceTouch, dependenciesFile let package = match model |> Map.tryFind (kv.Key, ps.Name) with - | Some (p,_) -> Choice1Of2 p + | Some (p,_,_) -> Choice1Of2 p | None -> Choice2Of2 <| sprintf " - %s uses NuGet package %O, but it was not found in the paket.lock file in group %O.%s" referenceFile.FileName ps.Name kv.Key (lockFile.CheckIfPackageExistsInAnyGroup ps.Name) match group, package with @@ -498,7 +508,7 @@ let InstallIntoProjects(options : InstallerOptions, forceTouch, dependenciesFile let allKnownLibs = model - |> Seq.map (fun kv -> (snd kv.Value).GetLibReferencesLazy.Force()) + |> Seq.map (fun kv -> (sndOf3 kv.Value).GetLibReferencesLazy.Force()) |> Set.unionMany for g in lockFile.Groups do @@ -511,7 +521,7 @@ let InstallIntoProjects(options : InstallerOptions, forceTouch, dependenciesFile |> Map.tryFind (snd kv.Key) |> Option.bind (fun p -> p.Settings.CreateBindingRedirects) - (snd kv.Value,packageRedirects)) + (sndOf3 kv.Value,packageRedirects)) |> applyBindingRedirects !first options.CreateNewBindingFiles diff --git a/src/Paket.Core/Utils.fs b/src/Paket.Core/Utils.fs index 059f9aff24..d366926bf3 100644 --- a/src/Paket.Core/Utils.fs +++ b/src/Paket.Core/Utils.fs @@ -21,6 +21,10 @@ ServicePointManager.SecurityProtocol <- unbox 192 ||| unbox 768 ||| unbox 3072 | ///SecurityProtocolType.Tls ||| SecurityProtocolType.Tls11 ||| SecurityProtocolType.Tls12 ||| SecurityProtocolType.Ssl3 #endif +let sndOf3 (_,v,_) = v +let thirdOf3 (_,_,v) = v + + /// Adds quotes around the string /// [omit] let quote (str:string) = "\"" + str.Replace("\"","\\\"") + "\""