From b68311b691aebe8f421ba517d7b0fded585e7dab Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Mon, 2 Oct 2017 11:17:45 +0200 Subject: [PATCH 1/2] 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 From 7e4acae3daba2873453949d76937168e1712b8f4 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Mon, 2 Oct 2017 13:31:46 +0200 Subject: [PATCH 2/2] Remove dnxcore50 moniker from lock file - fixes #2810 --- tests/Paket.Tests/NuGetOData/ODataSpecs.fs | 22 -------- .../NuGetOData/WindowsAzure.Storage.xml | 51 ------------------- tests/Paket.Tests/Paket.Tests.fsproj | 5 +- 3 files changed, 1 insertion(+), 77 deletions(-) delete mode 100644 tests/Paket.Tests/NuGetOData/WindowsAzure.Storage.xml diff --git a/tests/Paket.Tests/NuGetOData/ODataSpecs.fs b/tests/Paket.Tests/NuGetOData/ODataSpecs.fs index d7b7d96f67..3f2c6ce67b 100644 --- a/tests/Paket.Tests/NuGetOData/ODataSpecs.fs +++ b/tests/Paket.Tests/NuGetOData/ODataSpecs.fs @@ -149,28 +149,6 @@ let ``can detect explicit dependencies for Microsoft.AspNet.WebApi.Client``() = FrameworkRestriction.And [getPortableRestriction("portable-net45+win8+wp8+wp81+wpa81"); FrameworkRestriction.NotAtLeast(DotNetFramework(FrameworkVersion.V4_5))] |> ExplicitRestriction) -[] -let ``can detect explicit dependencies for WindowsAzure.Storage``() = - let odata = parseList "NuGetOData/WindowsAzure.Storage.xml" |> ODataSearchResult.get - odata.PackageName |> shouldEqual "WindowsAzure.Storage" - odata.DownloadUrl |> shouldEqual"https://www.nuget.org/api/v2/package/WindowsAzure.Storage/4.4.1-preview" - let dependencies = odata|> NuGet.NuGetPackageCache.getDependencies |> Array.ofList - dependencies.[0] |> shouldEqual - (PackageName "Microsoft.Data.OData", DependenciesFileParser.parseVersionRequirement(">= 5.6.3"), - makeOrList [FrameworkRestriction.AtLeast(DNXCore(FrameworkVersion.V5_0))]) - - let vr,pr = - match DependenciesFileParser.parseVersionRequirement(">= 4.0.0-beta-22231") with - | VersionRequirement(vr,pr) -> vr,pr - - dependencies.[18] |> shouldEqual - (PackageName "System.Net.Http", VersionRequirement(vr,PreReleaseStatus.All), - makeOrList [FrameworkRestriction.AtLeast(DNXCore(FrameworkVersion.V5_0))]) - - dependencies.[44] |> shouldEqual - (PackageName "Newtonsoft.Json", DependenciesFileParser.parseVersionRequirement(">= 6.0.8"), - makeOrList [FrameworkRestriction.AtLeast(WindowsPhone WindowsPhoneVersion.V8); FrameworkRestriction.AtLeast(DotNetFramework(FrameworkVersion.V4))]) - [] let ``can ignore unknown frameworks``() = let parsed = parseList "NuGetOData/BenchmarkDotNet-UnknownFramework.xml" |> ODataSearchResult.get diff --git a/tests/Paket.Tests/NuGetOData/WindowsAzure.Storage.xml b/tests/Paket.Tests/NuGetOData/WindowsAzure.Storage.xml deleted file mode 100644 index 332fdc7ba0..0000000000 --- a/tests/Paket.Tests/NuGetOData/WindowsAzure.Storage.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - https://www.nuget.org/api/v2/Packages - Packages - 2015-07-16T08:58:27Z - - - https://www.nuget.org/api/v2/Packages(Id='WindowsAzure.Storage',Version='4.4.1-preview') - - - WindowsAzure.Storage - A client library for working with Microsoft Azure storage services including blobs, files, tables, and queues. - 2015-07-15T13:47:30Z - - Microsoft - - - - - 4.4.1-preview - 4.4.1-preview - - 2015-05-13T19:25:02.153 - Microsoft.Data.OData:5.6.3:aspnetcore50|Microsoft.Data.Services.Client:5.6.3:aspnetcore50|System.Spatial:5.6.3:aspnetcore50|System.Collections:4.0.10-beta-22231:aspnetcore50|System.Collections.Concurrent:4.0.0-beta-22231:aspnetcore50|System.Collections.Specialized:4.0.0-beta-22231:aspnetcore50|System.Diagnostics.Debug:4.0.10-beta-22231:aspnetcore50|System.Diagnostics.Tools:4.0.0-beta-22231:aspnetcore50|System.Diagnostics.TraceSource:4.0.0-beta-22231:aspnetcore50|System.Diagnostics.Tracing:4.0.10-beta-22231:aspnetcore50|System.Dynamic.Runtime:4.0.0-beta-22231:aspnetcore50|System.Globalization:4.0.10-beta-22231:aspnetcore50|System.IO:4.0.10-beta-22231:aspnetcore50|System.IO.FileSystem:4.0.0-beta-22231:aspnetcore50|System.IO.FileSystem.Primitives:4.0.0-beta-22231:aspnetcore50|System.Linq:4.0.0-beta-22231:aspnetcore50|System.Linq.Expressions:4.0.0-beta-22231:aspnetcore50|System.Linq.Queryable:4.0.0-beta-22231:aspnetcore50|System.Net.Http:4.0.0-beta-22231:aspnetcore50|System.Net.Primitives:4.0.10-beta-22231:aspnetcore50|System.Reflection:4.0.10-beta-22231:aspnetcore50|System.Reflection.Extensions:4.0.0-beta-22231:aspnetcore50|System.Reflection.TypeExtensions:4.0.0-beta-22231:aspnetcore50|System.Runtime:4.0.20-beta-22231:aspnetcore50|System.Runtime.Extensions:4.0.10-beta-22231:aspnetcore50|System.Runtime.InteropServices:4.0.20-beta-22231:aspnetcore50|System.Runtime.Serialization.Primitives:4.0.0-beta-22231:aspnetcore50|System.Runtime.Serialization.Xml:4.0.10-beta-22231:aspnetcore50|System.Security.Cryptography.Encoding:4.0.0-beta-22231:aspnetcore50|System.Security.Cryptography.Encryption:4.0.0-beta-22231:aspnetcore50|System.Security.Cryptography.Hashing:4.0.0-beta-22231:aspnetcore50|System.Security.Cryptography.Hashing.Algorithms:4.0.0-beta-22231:aspnetcore50|System.Text.Encoding:4.0.10-beta-22231:aspnetcore50|System.Text.Encoding.Extensions:4.0.10-beta-22231:aspnetcore50|System.Text.RegularExpressions:4.0.10-beta-22231:aspnetcore50|System.Threading:4.0.0-beta-22231:aspnetcore50|System.Threading.Tasks:4.0.10-beta-22231:aspnetcore50|System.Threading.Thread:4.0.0-beta-22231:aspnetcore50|System.Threading.ThreadPool:4.0.10-beta-22231:aspnetcore50|System.Threading.Timer:4.0.0-beta-22231:aspnetcore50|System.Xml.ReaderWriter:4.0.10-beta-22231:aspnetcore50|System.Xml.XDocument:4.0.0-beta-22231:aspnetcore50|System.Xml.XmlSerializer:4.0.0-beta-22231:aspnetcore50|Microsoft.Data.OData:5.6.3:aspnet50|Microsoft.Data.Services.Client:5.6.3:aspnet50|System.Spatial:5.6.3:aspnet50|Microsoft.Data.OData:5.6.2:net40-Client|Newtonsoft.Json:6.0.8:net40-Client|Microsoft.Data.Services.Client:5.6.2:net40-Client|Microsoft.WindowsAzure.ConfigurationManager:1.8.0.0:net40-Client|Microsoft.Azure.KeyVault.Core:0.9.1-preview:net40-Client|Microsoft.Data.OData:5.6.2:win80|Microsoft.Data.OData:5.6.2:wpa|Microsoft.Data.OData:5.6.2:wp80|Newtonsoft.Json:6.0.8:wp80|Microsoft.Azure.KeyVault.Core:0.9.1-preview:wp80|Microsoft.Data.OData:5.6.4:portable-net45+win+wpa81+MonoAndroid10+MonoTouch10 - This client library enables working with the Microsoft Azure storage services which include the blob and file service for storing binary and text data, the table service for storing structured non-relational data, and the queue service for storing messages that may be accessed by a client. For this release see notes - https://github.com/Azure/azure-storage-net/blob/master/README.md and https://github.com/Azure/azure-storage-net/blob/master/changelog.txt Microsoft Azure Storage team's blog - http://blogs.msdn.com/b/windowsazurestorage/ - 2622119 - https://www.nuget.org/packages/WindowsAzure.Storage/4.4.1-preview - http://go.microsoft.com/fwlink/?LinkID=288890 - false - true - true - - 2015-05-13T19:25:02.153 - Yea3N7FUEbq/wgH1yKKv1ku2zaL0AGGckX/oXVTck7XzWWUhyu6/fc/wcfRrTgg+k6TDChDDQgmq1/GMq1cjbg== - SHA512 - 2197626 - http://go.microsoft.com/fwlink/?LinkId=235168 - https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/4.4.1-preview - - true - Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial - Windows Azure Storage - 3802 - 2.8.3 - - http://go.microsoft.com/fwlink/?LinkId=331471 - - - - - \ No newline at end of file diff --git a/tests/Paket.Tests/Paket.Tests.fsproj b/tests/Paket.Tests/Paket.Tests.fsproj index e7d74e7f46..88d856ecbb 100644 --- a/tests/Paket.Tests/Paket.Tests.fsproj +++ b/tests/Paket.Tests/Paket.Tests.fsproj @@ -1,4 +1,4 @@ - + @@ -168,9 +168,6 @@ Always - - Always - Always