Skip to content

Commit

Permalink
Better parsing of framework restrictions - references #1232
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Nov 17, 2015
1 parent ab3ed8a commit 565cbf9
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 6 deletions.
3 changes: 2 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source https://nuget.org/api/v2

framework: >=net40

nuget System.Data.SQLite 1.0.98.1 content: none
9 changes: 7 additions & 2 deletions src/Paket.Core/DependenciesFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -492,7 +495,7 @@ type DependenciesFile(fileName,groups:Map<GroupName,DependenciesGroup>, textRepr
Settings = group.Options.Settings })
|> Seq.toList

{ ResolvedPackages =
let resolution =
PackageResolver.Resolve(
groupName,
group.Sources,
Expand All @@ -502,6 +505,8 @@ type DependenciesFile(fileName,groups:Map<GroupName,DependenciesGroup>, textRepr
group.Options.Settings.FrameworkRestrictions,
remoteDependencies @ group.Packages |> Set.ofList,
updateMode)

{ ResolvedPackages = resolution
ResolvedSourceFiles = remoteFiles }

groupsToResolve
Expand Down
6 changes: 5 additions & 1 deletion src/Paket.Core/Requirements.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion src/Paket/Paket.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<StartWorkingDirectory>d:\code\paketkopie</StartWorkingDirectory>
<StartWorkingDirectory>d:\code\paketbug</StartWorkingDirectory>
<StartWorkingDirectory>d:\code\paketrepro</StartWorkingDirectory>
<StartWorkingDirectory>D:\code\Paket\integrationtests\scenarios\i001233-props-files\temp\</StartWorkingDirectory>
<StartWorkingDirectory>D:\code\Paket\integrationtests\scenarios\i001232-sql-lite\temp\</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand Down
16 changes: 15 additions & 1 deletion tests/Paket.Tests/DependenciesFile/ParserSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
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
"""

[<Test>]
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))]

0 comments on commit 565cbf9

Please sign in to comment.