Skip to content

Commit f82f396

Browse files
committed
Allow specify auto-detect in specific groups - fixes #2011
1 parent 9ab1d88 commit f82f396

5 files changed

Lines changed: 84 additions & 29 deletions

File tree

‎RELEASE_NOTES.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#### 3.30.1 - 25.11.2016
2+
* BUGFIX: Allow specify auto-detect in specific groups - https://github.com/fsprojects/Paket/issues/2011
3+
14
#### 3.30.0 - 22.11.2016
25
* Allow override of NuGetCacheFolder location through environment variable - https://github.com/fsprojects/Paket/pull/2035
36
* BUGFIX: Add authorization headers to Paket Push - https://github.com/fsprojects/Paket/pull/2034

‎src/Paket.Core/Requirements.fs‎

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -446,40 +446,42 @@ let combineRestrictions loose (x : FrameworkRestriction) y =
446446
[]
447447

448448
let filterRestrictions (list1:FrameworkRestrictions) (list2:FrameworkRestrictions) =
449-
let list1 = getRestrictionList list1
450-
let list2 = getRestrictionList list2
451-
452-
let filtered =
453-
match list1, list2 with
454-
| [],_ -> list2
455-
| _,[] -> list1
456-
| _ ->
457-
[for x in list1 do
458-
for y in list2 do
459-
let c = combineRestrictions false x y
460-
if c <> [] then yield! c]
461-
462-
let tryLoose =
463-
(filtered |> List.exists (fun r -> match r.GetOneIdentifier with | Some (FrameworkIdentifier.DotNetFramework _ ) -> true | _ -> false) |> not) &&
464-
(list2 |> List.exists (fun r -> match r.GetOneIdentifier with | Some (FrameworkIdentifier.DotNetFramework _ ) -> true | _ -> false))
465-
466-
let filtered =
467-
if tryLoose then
449+
match list1,list2 with
450+
| FrameworkRestrictionList [], AutoDetectFramework -> AutoDetectFramework
451+
| AutoDetectFramework, FrameworkRestrictionList [] -> AutoDetectFramework
452+
| FrameworkRestrictionList list1 , FrameworkRestrictionList list2 ->
453+
let filtered =
468454
match list1, list2 with
469455
| [],_ -> list2
470456
| _,[] -> list1
471457
| _ ->
472458
[for x in list1 do
473459
for y in list2 do
474-
let c = combineRestrictions true x y
460+
let c = combineRestrictions false x y
475461
if c <> [] then yield! c]
476-
else
477-
filtered
478462

479-
let optimized =
480-
filtered
481-
|> optimizeRestrictions
482-
FrameworkRestrictionList optimized
463+
let tryLoose =
464+
(filtered |> List.exists (fun r -> match r.GetOneIdentifier with | Some (FrameworkIdentifier.DotNetFramework _ ) -> true | _ -> false) |> not) &&
465+
(list2 |> List.exists (fun r -> match r.GetOneIdentifier with | Some (FrameworkIdentifier.DotNetFramework _ ) -> true | _ -> false))
466+
467+
let filtered =
468+
if tryLoose then
469+
match list1, list2 with
470+
| [],_ -> list2
471+
| _,[] -> list1
472+
| _ ->
473+
[for x in list1 do
474+
for y in list2 do
475+
let c = combineRestrictions true x y
476+
if c <> [] then yield! c]
477+
else
478+
filtered
479+
480+
let optimized =
481+
filtered
482+
|> optimizeRestrictions
483+
FrameworkRestrictionList optimized
484+
| _ -> failwithf "The framework restriction %O and %O could not be combined." list1 list2
483485

484486
/// Get if a target should be considered with the specified restrictions
485487
let isTargetMatchingRestrictions =

‎src/Paket/Paket.fsproj‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@
5757
<StartWorkingDirectory>D:\temp\repo3</StartWorkingDirectory>
5858
<StartArguments>install -v</StartArguments>
5959
<StartWorkingDirectory>D:\temp\IconPacksTestApp\src</StartWorkingDirectory>
60-
<StartArguments>pack output nugets</StartArguments>
61-
<StartWorkingDirectory>D:\temp\PaketRepro</StartWorkingDirectory>
60+
<StartArguments>install</StartArguments>
61+
<StartWorkingDirectory>D:\temp\ReproPaketFwkAutodetectAndGroup\</StartWorkingDirectory>
6262
</PropertyGroup>
6363
<PropertyGroup>
6464
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>

‎src/Paket/Program.fs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,8 @@ let generateIncludeScripts (results : ParseResults<GenerateIncludeScriptsArgs>)
298298
let frameworksForDependencyGroups = lazy (
299299
dependencies.Groups
300300
|> Seq.map (fun f -> f.Value.Options.Settings.FrameworkRestrictions)
301-
|> Seq.map(function
301+
|> Seq.map(fun resttrictions ->
302+
match resttrictions with
302303
| Paket.Requirements.AutoDetectFramework -> failwithf "couldn't detect framework"
303304
| Paket.Requirements.FrameworkRestrictionList list ->
304305
list |> Seq.collect (

‎tests/Paket.Tests/DependenciesFile/ParserSpecs.fs‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,3 +1384,52 @@ let ``async cache should work``() =
13841384
} |> Async.RunSynchronously
13851385
!x |> shouldEqual 1
13861386

1387+
let autodetectconfig = """
1388+
framework: auto-detect
1389+
source https://api.nuget.org/v3/index.json
1390+
nuget nlog
1391+
1392+
group build
1393+
framework: net4.5.2
1394+
source https://www.nuget.org/api/v2
1395+
1396+
nuget GitVersion
1397+
1398+
group tests
1399+
framework: net4.5.2
1400+
source https://www.nuget.org/api/v2
1401+
1402+
nuget xunit
1403+
"""
1404+
1405+
[<Test>]
1406+
let ``should read autodetect from main group``() =
1407+
let cfg = DependenciesFile.FromCode(autodetectconfig)
1408+
cfg.Groups.[Constants.MainDependencyGroup].Options.Settings.FrameworkRestrictions
1409+
|> shouldEqual FrameworkRestrictions.AutoDetectFramework
1410+
1411+
let autodetectconfigSpecific = """
1412+
//`auto-detect` with explicit 'Main' group fails
1413+
group Main
1414+
framework: auto-detect
1415+
source https://api.nuget.org/v3/index.json
1416+
nuget nlog
1417+
1418+
group build
1419+
framework: net4.5.2
1420+
source https://www.nuget.org/api/v2
1421+
1422+
nuget GitVersion
1423+
1424+
group tests
1425+
framework: net4.5.2
1426+
source https://www.nuget.org/api/v2
1427+
1428+
nuget xunit
1429+
"""
1430+
1431+
[<Test>]
1432+
let ``should read autodetect from specific main group``() =
1433+
let cfg = DependenciesFile.FromCode(autodetectconfigSpecific)
1434+
cfg.Groups.[Constants.MainDependencyGroup].Options.Settings.FrameworkRestrictions
1435+
|> shouldEqual FrameworkRestrictions.AutoDetectFramework

0 commit comments

Comments
 (0)