diff --git a/src/Paket.Core/InstallModel.fs b/src/Paket.Core/InstallModel.fs index 693d2a616b..8afb16de85 100644 --- a/src/Paket.Core/InstallModel.fs +++ b/src/Paket.Core/InstallModel.fs @@ -288,25 +288,7 @@ type InstallModel = | [] -> this | restrictions -> let applRestriction folder = - { folder with - Targets = - folder.Targets - |> List.filter - (function - | SinglePlatform pf -> - restrictions - |> List.exists (fun restriction -> - match restriction with - | FrameworkRestriction.Exactly fw -> pf = fw - | FrameworkRestriction.Portable r -> false - | FrameworkRestriction.AtLeast fw -> pf >= fw - | FrameworkRestriction.Between(min,max) -> pf >= min && pf < max) - | _ -> - restrictions - |> List.exists (fun restriction -> - match restriction with - | FrameworkRestriction.Portable r -> true - | _ -> false))} + { folder with Targets = applyRestrictionsToTargets restrictions folder.Targets} {this with ReferenceFileFolders = diff --git a/src/Paket.Core/Requirements.fs b/src/Paket.Core/Requirements.fs index 7ab980a905..d995724b72 100644 --- a/src/Paket.Core/Requirements.fs +++ b/src/Paket.Core/Requirements.fs @@ -213,6 +213,29 @@ let filterRestrictions (list1:FrameworkRestrictions) (list2:FrameworkRestriction if c <> [] then yield! c] |> optimizeRestrictions +/// Get if a target should be considered with the specified restrictions +let isTargetMatchingRestrictions (restrictions:FrameworkRestrictions) = function + | SinglePlatform pf -> + restrictions + |> List.exists (fun restriction -> + match restriction with + | FrameworkRestriction.Exactly fw -> pf = fw + | FrameworkRestriction.Portable _ -> false + | FrameworkRestriction.AtLeast fw -> pf >= fw + | FrameworkRestriction.Between(min,max) -> pf >= min && pf < max) + | _ -> + restrictions + |> List.exists (fun restriction -> + match restriction with + | FrameworkRestriction.Portable r -> true + | _ -> false) + +/// Get all targets that should be considered with the specified restrictions +let applyRestrictionsToTargets (restrictions:FrameworkRestrictions) (targets: TargetProfile list) = + let result = targets |> List.filter (isTargetMatchingRestrictions restrictions) + result + + type ContentCopySettings = | Omit | Overwrite