From 565cbf9b9acf8aa5618b35faac223b51a178f5f0 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Tue, 17 Nov 2015 19:56:04 +0100 Subject: [PATCH] Better parsing of framework restrictions - references #1232 --- RELEASE_NOTES.md | 3 ++- .../i001232-sql-lite/before/paket.dependencies | 5 +++++ src/Paket.Core/DependenciesFile.fs | 9 +++++++-- src/Paket.Core/Requirements.fs | 6 +++++- src/Paket/Paket.fsproj | 2 +- .../Paket.Tests/DependenciesFile/ParserSpecs.fs | 16 +++++++++++++++- 6 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 integrationtests/scenarios/i001232-sql-lite/before/paket.dependencies diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 356da4177b..994867c2b8 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,5 +1,6 @@ -#### 2.26.0-alpha006 - 17.11.2015 +#### 2.26.0-alpha007 - 17.11.2015 * Try all 4 NuGet APIs for "GetPackageDetails" in parallel - https://github.com/fsprojects/Paket/issues/1225 +* BUGFIX: Better parsing of framework restrictions - https://github.com/fsprojects/Paket/issues/1232 * BUGFIX: Fix props files - https://github.com/fsprojects/Paket/issues/1233 * BUGFIX: Detect AssemblyName from project file name if empty - https://github.com/fsprojects/Paket/issues/1234 * BUGFIX: Fixed issue with V3 feeds doing api requests even when the paket.lock is fully specified - https://github.com/fsprojects/Paket/pull/1231 diff --git a/integrationtests/scenarios/i001232-sql-lite/before/paket.dependencies b/integrationtests/scenarios/i001232-sql-lite/before/paket.dependencies new file mode 100644 index 0000000000..b41ffabe09 --- /dev/null +++ b/integrationtests/scenarios/i001232-sql-lite/before/paket.dependencies @@ -0,0 +1,5 @@ +source https://nuget.org/api/v2 + +framework: >=net40 + +nuget System.Data.SQLite 1.0.98.1 content: none \ No newline at end of file diff --git a/src/Paket.Core/DependenciesFile.fs b/src/Paket.Core/DependenciesFile.fs index f5966d137f..4d0c03a70c 100644 --- a/src/Paket.Core/DependenciesFile.fs +++ b/src/Paket.Core/DependenciesFile.fs @@ -235,7 +235,10 @@ module DependenciesFileParser = | _ -> None ParserOptions(ParserOption.ResolverStrategy(setting)) - | String.StartsWith "framework" trimmed -> ParserOptions(ParserOption.FrameworkRestrictions(trimmed.Replace(":","").Trim() |> Requirements.parseRestrictions)) + | String.StartsWith "framework" trimmed -> + let text = trimmed.Replace(":","").Trim() + let restriction = Requirements.parseRestrictions text + ParserOptions(ParserOption.FrameworkRestrictions restriction) | String.StartsWith "content" trimmed -> let setting = match trimmed.Replace(":","").Trim().ToLowerInvariant() with @@ -492,7 +495,7 @@ type DependenciesFile(fileName,groups:Map, textRepr Settings = group.Options.Settings }) |> Seq.toList - { ResolvedPackages = + let resolution = PackageResolver.Resolve( groupName, group.Sources, @@ -502,6 +505,8 @@ type DependenciesFile(fileName,groups:Map, textRepr group.Options.Settings.FrameworkRestrictions, remoteDependencies @ group.Packages |> Set.ofList, updateMode) + + { ResolvedPackages = resolution ResolvedSourceFiles = remoteFiles } groupsToResolve diff --git a/src/Paket.Core/Requirements.fs b/src/Paket.Core/Requirements.fs index 253f60c1d5..657cb25b95 100644 --- a/src/Paket.Core/Requirements.fs +++ b/src/Paket.Core/Requirements.fs @@ -37,9 +37,13 @@ type FrameworkRestrictions = FrameworkRestriction list let parseRestrictions(text:string) = + let text = + // workaround missing spaces + text.Replace("<=","<= ").Replace(">=",">= ").Replace("=","= ") + let commaSplit = text.Trim().Split(',') [for p in commaSplit do - let operatorSplit = p.Trim().Split(' ') + let operatorSplit = p.Trim().Split([|' '|],StringSplitOptions.RemoveEmptyEntries) let framework = if operatorSplit.Length < 2 then operatorSplit.[0] diff --git a/src/Paket/Paket.fsproj b/src/Paket/Paket.fsproj index 16627da979..68a077c143 100644 --- a/src/Paket/Paket.fsproj +++ b/src/Paket/Paket.fsproj @@ -45,7 +45,7 @@ d:\code\paketkopie d:\code\paketbug d:\code\paketrepro - D:\code\Paket\integrationtests\scenarios\i001233-props-files\temp\ + D:\code\Paket\integrationtests\scenarios\i001232-sql-lite\temp\ pdbonly diff --git a/tests/Paket.Tests/DependenciesFile/ParserSpecs.fs b/tests/Paket.Tests/DependenciesFile/ParserSpecs.fs index 28cd83870b..403f2f94d8 100644 --- a/tests/Paket.Tests/DependenciesFile/ParserSpecs.fs +++ b/tests/Paket.Tests/DependenciesFile/ParserSpecs.fs @@ -966,4 +966,18 @@ let ``should read config with very similar feeds``() = cfg.Groups.[Constants.MainDependencyGroup].Sources.Head.Url |> shouldEqual "http://nexus1:8081/nexus/service/local/nuget/nuget-repo" cfg.Groups.[Constants.MainDependencyGroup].Sources.Tail.Head.Auth |> shouldNotEqual None - cfg.Groups.[Constants.MainDependencyGroup].Sources.Tail.Head.Url |> shouldEqual "http://nexus2:8081/nexus/service/local/nuget/nuget-repo" \ No newline at end of file + cfg.Groups.[Constants.MainDependencyGroup].Sources.Tail.Head.Url |> shouldEqual "http://nexus2:8081/nexus/service/local/nuget/nuget-repo" + +let configTargetFramework = """source https://nuget.org/api/v2 + +framework: >=net40 + +nuget System.Data.SQLite 1.0.98.1 content: none +""" + +[] +let ``should read config with target framework``() = + let cfg = DependenciesFile.FromCode(configTargetFramework) + + cfg.Groups.[Constants.MainDependencyGroup].Options.Settings.FrameworkRestrictions + |> shouldEqual [FrameworkRestriction.AtLeast(FrameworkIdentifier.DotNetFramework(FrameworkVersion.V4_Client))] \ No newline at end of file