From b68311b691aebe8f421ba517d7b0fded585e7dab Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Mon, 2 Oct 2017 11:17:45 +0200 Subject: [PATCH] Remove dnxcore50 moniker from lock file - fixes #2810 --- .../Dependencies/DependenciesFileParser.fs | 1 - src/Paket.Core/Dependencies/NuGetCache.fs | 15 +++++++++----- src/Paket.Core/Dependencies/NuGetV2.fs | 3 ++- src/Paket.Core/Dependencies/Nuspec.fs | 9 +++++---- .../Versioning/FrameworkHandling.fs | 10 +++++++++- src/Paket.Core/Versioning/PlatformMatching.fs | 6 +++++- src/Paket.Core/Versioning/Requirements.fs | 20 +++++++++++-------- src/Paket/Paket.fsproj | 4 ++-- 8 files changed, 45 insertions(+), 23 deletions(-) diff --git a/src/Paket.Core/Dependencies/DependenciesFileParser.fs b/src/Paket.Core/Dependencies/DependenciesFileParser.fs index 6ac0af4d9e..b554819b89 100644 --- a/src/Paket.Core/Dependencies/DependenciesFileParser.fs +++ b/src/Paket.Core/Dependencies/DependenciesFileParser.fs @@ -81,7 +81,6 @@ module DependenciesFileParser = match VersionRange.BasicOperators |> List.tryFind(text.StartsWith) with | Some token -> token, text.Replace(token + " ", "").Split ' ' |> Array.toList | None -> "=", text.Split ' ' |> Array.toList - match splitVersion text with | "==", version :: rest -> diff --git a/src/Paket.Core/Dependencies/NuGetCache.fs b/src/Paket.Core/Dependencies/NuGetCache.fs index e17263ee5a..1cd22c5315 100644 --- a/src/Paket.Core/Dependencies/NuGetCache.fs +++ b/src/Paket.Core/Dependencies/NuGetCache.fs @@ -70,7 +70,7 @@ type NuGetRequestGetVersions = } -// An unparsed file in the nuget package -> still need to inspect the path for further information. After parsing an entry will be part of a "LibFolder" for example. +// An unparsed file in the NuGet package -> still need to inspect the path for further information. After parsing an entry will be part of a "LibFolder" for example. type UnparsedPackageFile = { FullPath : string PathWithinPackage : string } @@ -128,16 +128,18 @@ type NuGetPackageCache = let restrictionString = match restrictions with | FrameworkRestrictions.AutoDetectFramework -> "AUTO" - | FrameworkRestrictions.ExplicitRestriction re -> - re.ToString() + | FrameworkRestrictions.ExplicitRestriction re -> re.ToString() n, v, restrictionString) } + static member getDependencies (x:NuGetPackageCache) : (PackageName * VersionRequirement * FrameworkRestrictions) list = x.SerializedDependencies |> List.map (fun (n,v,restrictionString) -> let restrictions = if restrictionString = "AUTO" then FrameworkRestrictions.AutoDetectFramework - else FrameworkRestrictions.ExplicitRestriction(Requirements.parseRestrictions restrictionString |> fst) + else + let restrictions = Requirements.parseRestrictions restrictionString |> fst + FrameworkRestrictions.ExplicitRestriction restrictions n, v, restrictions) let inline normalizeUrl(url:string) = url.Replace("https://","http://").Replace("www.","") @@ -159,6 +161,7 @@ let getCacheFiles cacheVersion nugetURL (packageName:PackageName) (version:SemVe type ODataSearchResult = | EmptyResult | Match of NuGetPackageCache + module ODataSearchResult = let get x = match x with @@ -176,7 +179,8 @@ let tryGetDetailsFromCache force nugetURL (packageName:PackageName) (version:Sem if (PackageName cachedObject.PackageName <> packageName) || (cachedObject.Version <> version.Normalize()) then - traceVerbose (sprintf "Invalidating Cache '%s:%s' <> '%s:%s'" cachedObject.PackageName cachedObject.Version packageName.Name (version.Normalize())) + if verbose then + traceVerbose (sprintf "Invalidating Cache '%s:%s' <> '%s:%s'" cachedObject.PackageName cachedObject.Version packageName.Name (version.Normalize())) cacheFile.Delete() None else @@ -292,6 +296,7 @@ let rec private cleanup (dir : DirectoryInfo) = let GetTargetUserFolder packageName (version:SemVerInfo) = DirectoryInfo(Path.Combine(Constants.UserNuGetPackagesFolder,packageName.ToString(),version.Normalize())).FullName + let GetTargetUserNupkg packageName (version:SemVerInfo) = let normalizedNupkgName = GetPackageFileName packageName version let path = GetTargetUserFolder packageName version diff --git a/src/Paket.Core/Dependencies/NuGetV2.fs b/src/Paket.Core/Dependencies/NuGetV2.fs index 03cff4a2df..202c5f4c14 100644 --- a/src/Paket.Core/Dependencies/NuGetV2.fs +++ b/src/Paket.Core/Dependencies/NuGetV2.fs @@ -188,7 +188,8 @@ let private handleODataEntry nugetURL packageName version entry = (if a.Length > 2 && a.[2] <> "" then let restriction = a.[2] match PlatformMatching.extractPlatforms false restriction with - | Some p -> Some p + | Some p -> + Some { p with Platforms = p.Platforms |> List.filter KnownTargetProfiles.isSupportedProfile } | None -> Logging.traceWarnIfNotBefore ("Package", restriction, packageName, version) "Could not detect any platforms from '%s' in package %O %O, please tell the package authors" restriction packageName version None diff --git a/src/Paket.Core/Dependencies/Nuspec.fs b/src/Paket.Core/Dependencies/Nuspec.fs index 910b846184..7f00ade731 100644 --- a/src/Paket.Core/Dependencies/Nuspec.fs +++ b/src/Paket.Core/Dependencies/Nuspec.fs @@ -51,7 +51,9 @@ module internal NuSpecParserHelper = | Some name, Some targetFrameworks -> targetFrameworks.Split([|','; ' '|],System.StringSplitOptions.RemoveEmptyEntries) |> Array.choose FrameworkDetection.Extract - |> Array.map (fun fw -> { AssemblyName = name; FrameworkRestrictions = ExplicitRestriction (FrameworkRestriction.Exactly fw) }) + |> Array.map (fun fw -> + { AssemblyName = name + FrameworkRestrictions = ExplicitRestriction (FrameworkRestriction.Exactly fw) }) |> Array.toList | _ -> [] @@ -99,8 +101,7 @@ type Nuspec = let dependencies = lazy - let dependencies, warnings = - addFrameworkRestrictionsToDependencies rawDependencies frameworks + let dependencies, warnings = addFrameworkRestrictionsToDependencies rawDependencies frameworks for warning in warnings do Logging.traceWarnfn "%s" (warning.Format name version) dependencies @@ -134,7 +135,7 @@ type Nuspec = FrameworkRestrictions = ExplicitRestriction( restrictions - |> List.map (fun x -> x.FrameworkRestrictions |> getExplicitRestriction) + |> List.map (fun x -> getExplicitRestriction x.FrameworkRestrictions) |> List.fold FrameworkRestriction.combineRestrictionsWithOr FrameworkRestriction.EmptySet) } ] } /// load the file from an nuspec text stream. The fileName is only used for error reporting. diff --git a/src/Paket.Core/Versioning/FrameworkHandling.fs b/src/Paket.Core/Versioning/FrameworkHandling.fs index 19dcfede12..ccb61e9bb3 100644 --- a/src/Paket.Core/Versioning/FrameworkHandling.fs +++ b/src/Paket.Core/Versioning/FrameworkHandling.fs @@ -1217,6 +1217,12 @@ module KnownTargetProfiles = AllDotNetProfiles |> Set.ofList + let isSupportedProfile profile = + match profile with + | FrameworkIdentifier.DNX _ -> false + | FrameworkIdentifier.DNXCore _ -> false + | _ -> true + let TryFindPortableProfile (name:string) = let lowerName = name.ToLowerInvariant() AllProfiles @@ -1224,6 +1230,7 @@ module KnownTargetProfiles = |> Seq.tryPick (function | TargetProfile.PortableProfile p when p.ProfileName.ToLowerInvariant() = lowerName -> Some (TargetProfile.PortableProfile p) | _ -> None) + let FindPortableProfile name = match TryFindPortableProfile name with | Some s -> s @@ -1269,7 +1276,7 @@ module SupportCalculation = else // try to optimize on the 'pos' position let curPos = supported.[pos] - let supportList = buildSupportMap supportMap curPos // supportMap.[curPos] // + let supportList = buildSupportMap supportMap curPos (supported |> List.take pos |> List.filter (fun s -> supportList |> List.contains s |> not)) @ [curPos] @ (supported @@ -1291,6 +1298,7 @@ module SupportCalculation = if old.Count <> sup.Count then hasChanged <- true sup + let private getSupportedPortables p = getSupported p |> List.choose (function TargetProfile.PortableProfile p -> Some p | _ -> failwithf "Expected portable") diff --git a/src/Paket.Core/Versioning/PlatformMatching.fs b/src/Paket.Core/Versioning/PlatformMatching.fs index f4779d57cf..7272ce7ea9 100644 --- a/src/Paket.Core/Versioning/PlatformMatching.fs +++ b/src/Paket.Core/Versioning/PlatformMatching.fs @@ -28,7 +28,11 @@ let inline split (path : string) = // TODO: This function does now quite a lot, there probably should be several functions. let private extractPlatformsPriv = memoize (fun path -> let splits = split path - let platforms = splits |> Array.choose FrameworkDetection.Extract |> Array.toList + let platforms = + splits + |> Array.choose FrameworkDetection.Extract + |> Array.toList + if platforms.Length = 0 then if splits.Length = 1 && splits.[0].StartsWith "profile" then // might be something like portable4.6-profile151 diff --git a/src/Paket.Core/Versioning/Requirements.fs b/src/Paket.Core/Versioning/Requirements.fs index 5b91baa070..11e851a0c2 100644 --- a/src/Paket.Core/Versioning/Requirements.fs +++ b/src/Paket.Core/Versioning/Requirements.fs @@ -347,8 +347,7 @@ module FrameworkRestriction = |> List.filter (fun literal -> positiveSingles |> List.exists (fun p -> literal.IsNegated && literal.LiteraL = p.LiteraL) - |> not - ) + |> not) if reworkedAnd.Length < andFormula.Literals.Length then true, { Literals = reworkedAnd } :: reworkedOrFormulas else @@ -568,6 +567,7 @@ type FrameworkRestrictions = match x with | ExplicitRestriction r -> r.ToString() | AutoDetectFramework -> "AutoDetect" + member x.GetExplicitRestriction () = match x with | ExplicitRestriction list -> list @@ -598,6 +598,7 @@ type RestrictionParseProblem = | RestrictionParseProblem.UnsupportedPortable _ -> false | RestrictionParseProblem.ParseSecondOperator _ | RestrictionParseProblem.ParseFramework _ -> true + let parseRestrictionsLegacy failImmediatly (text:string) = // older lockfiles to the new "restriction" semantics let problems = ResizeArray<_>() @@ -655,7 +656,7 @@ let private parseRestrictionsRaw skipSimplify (text:string) = let rec parseOperator (text:string) = match text.Trim() with - | t when String.IsNullOrEmpty t -> failwithf "trying to parse an otherator but got no content" + | t when String.IsNullOrEmpty t -> failwithf "trying to parse an operator but got no content" | h when h.StartsWith ">=" || h.StartsWith "==" || h.StartsWith "<" -> // parse >= let smallerThan = h.StartsWith "<" @@ -714,7 +715,7 @@ let private parseRestrictionsRaw skipSimplify (text:string) = | { OrFormulas = [ {Literals = [ lit] } ] } -> [ {Literals = [ { lit with IsNegated = not lit.IsNegated } ] } ] |> FrameworkRestriction.FromOrList - | _ -> failwithf "a general NOT is not implemted jet (and shouldn't be emitted for now)" + | _ -> failwithf "a general NOT is not implemented (and shouldn't be emitted for now)" negated, next else failwithf "Expected operand after NOT, '%s'" text @@ -730,8 +731,7 @@ let private parseRestrictionsRaw skipSimplify (text:string) = let result, next = parseOperator text if String.IsNullOrEmpty next |> not then failwithf "Successfully parsed '%O' but got additional text '%s'" result next - result, - problems.ToArray() + result, problems.ToArray() let parseRestrictions = memoize (parseRestrictionsRaw false) let internal parseRestrictionsSimplified = parseRestrictionsRaw true @@ -1107,6 +1107,10 @@ let addFrameworkRestrictionsToDependencies rawDependencies (frameworkGroups:Pars if prof.IsSome && prof.Value.IsUnsupportedPortable then handleProblem <| UnknownPortableProfile prof.Value prof) + |> Seq.filter (fun frameworkGroup -> + match frameworkGroup with + | TargetProfile.SinglePlatform sp -> KnownTargetProfiles.isSupportedProfile sp + | _ -> true) // TODO: Check if this is needed (I think the logic below is a general version of this subset logic) |> Seq.filter (fun frameworkGroup -> // filter all restrictions which would render this group to nothing (ie smaller restrictions) @@ -1123,8 +1127,8 @@ let addFrameworkRestrictionsToDependencies rawDependencies (frameworkGroups:Pars let missing = FrameworkRestriction.combineRestrictionsWithAnd curRestr (FrameworkRestriction.AtLeastPlatform frameworkGroup) let combined = lazy FrameworkRestriction.combineRestrictionsWithAnd curRestr (FrameworkRestriction.NotAtLeastPlatform frameworkGroup) - match packageGroup.Platforms, missing.RepresentedFrameworks.IsEmpty with - | [ packageGroupFw ], false -> + match packageGroup.Platforms with + | [ packageGroupFw ] when not missing.RepresentedFrameworks.IsEmpty -> // the common set goes to the better matching one match PlatformMatching.findBestMatch (frameworkGroups, missing.RepresentedFrameworks.MinimumElement) with | Some { PlatformMatching.ParsedPlatformPath.Platforms = [ cfw ] } when cfw = packageGroupFw -> curRestr diff --git a/src/Paket/Paket.fsproj b/src/Paket/Paket.fsproj index 1b4bbeda6a..3204fc2e15 100644 --- a/src/Paket/Paket.fsproj +++ b/src/Paket/Paket.fsproj @@ -33,9 +33,9 @@ Project install C:\temp\Gu.Reactive - update + update -f C:\proj\Paket - D:\temp\androidTest + D:\code\fable-suave-scaffold true