diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 9c15d89b39..c78d6d6de1 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,6 +1,7 @@ #### 2.20.0 - 30.10.2015 * Allow filtered updates of packages matching a regex - https://github.com/fsprojects/Paket/pull/1178 * Search for paket.references in startup directory (auto-restore feature) - https://github.com/fsprojects/Paket/pull/1179 +* BUGFIX: Framework filtering for transisitve packages - https://github.com/fsprojects/Paket/issues/1182 #### 2.19.0 - 29.10.2015 * Resolver changed to breadth first search to escape more quickly from conflict situations - https://github.com/fsprojects/Paket/issues/1174 diff --git a/integrationtests/Paket.IntegrationTests/FrameworkRestrictionsSpecs.fs b/integrationtests/Paket.IntegrationTests/FrameworkRestrictionsSpecs.fs index 71000845ae..d0f0e2ef4a 100644 --- a/integrationtests/Paket.IntegrationTests/FrameworkRestrictionsSpecs.fs +++ b/integrationtests/Paket.IntegrationTests/FrameworkRestrictionsSpecs.fs @@ -14,4 +14,11 @@ open Paket.Requirements let ``#140 windsor should resolve framework dependent dependencies``() = let lockFile = update "i000140-resolve-framework-restrictions" lockFile.Groups.[Constants.MainDependencyGroup].Resolution.[PackageName "TaskParallelLibrary"].Settings.FrameworkRestrictions - |> shouldEqual [FrameworkRestriction.Exactly(DotNetFramework(FrameworkVersion.V3_5))] \ No newline at end of file + |> shouldEqual [FrameworkRestriction.Exactly(DotNetFramework(FrameworkVersion.V3_5))] + +[] +let ``#1182 framework restrictions overwrite each other``() = + let lockFile = update "i001182-framework-restrictions" + let lockFile = lockFile.ToString() + lockFile.Contains("Microsoft.Data.OData (>= 5.6.2) ") |> shouldEqual true + lockFile.Contains("framework: winv4.5") |> shouldEqual false \ No newline at end of file diff --git a/integrationtests/Paket.IntegrationTests/Paket.IntegrationTests.v2.ncrunchproject b/integrationtests/Paket.IntegrationTests/Paket.IntegrationTests.v2.ncrunchproject deleted file mode 100644 index ddaf8800c8..0000000000 Binary files a/integrationtests/Paket.IntegrationTests/Paket.IntegrationTests.v2.ncrunchproject and /dev/null differ diff --git a/integrationtests/scenarios/i001182-framework-restrictions/before/paket.dependencies b/integrationtests/scenarios/i001182-framework-restrictions/before/paket.dependencies new file mode 100644 index 0000000000..9cb1dbccbb --- /dev/null +++ b/integrationtests/scenarios/i001182-framework-restrictions/before/paket.dependencies @@ -0,0 +1,9 @@ +framework: net452 +content: none +redirects: off + +source https://www.nuget.org/api/v2/ +source https://nuget.bittitan.com/nuget/Components + + +nuget WindowsAzure.Storage 4.3.0 diff --git a/src/Paket.Core/PackageResolver.fs b/src/Paket.Core/PackageResolver.fs index b8f16dcc41..8102b3a34e 100644 --- a/src/Paket.Core/PackageResolver.fs +++ b/src/Paket.Core/PackageResolver.fs @@ -159,10 +159,11 @@ let calcOpenRequirements (exploredPackage:ResolvedPackage,globalFrameworkRestric let rest = Set.remove dependency stillOpen dependenciesByName - |> Set.map (fun (n, v, restriction) -> + |> Set.map (fun (n, v, restriction) -> let newRestrictions = filterRestrictions restriction exploredPackage.Settings.FrameworkRestrictions |> filterRestrictions globalFrameworkRestrictions + { dependency with Name = n VersionRequirement = v Parent = Package(dependency.Name, versionToExplore) @@ -230,7 +231,6 @@ let Resolve(groupName:GroupName, sources, getVersionsF, getPackageDetailsF, stra | _ -> tracefn " - %O %A" dependency.Name version let packageDetails : PackageDetails = getPackageDetailsF sources dependency.Name version - let restrictedDependencies = DependencySetFilter.filterByRestrictions newRestrictions packageDetails.DirectDependencies let settings = match dependency.Parent with | DependenciesFile(_) -> dependency.Settings @@ -238,13 +238,22 @@ let Resolve(groupName:GroupName, sources, getVersionsF, getPackageDetailsF, stra match rootSettings.TryGetValue packageDetails.Name with | true, s -> s + dependency.Settings | _ -> dependency.Settings + |> fun s -> s.AdjustWithSpecialCases packageDetails.Name + + let restrictedDependencies = + DependencySetFilter.filterByRestrictions newRestrictions packageDetails.DirectDependencies + |> Set.map (fun (n,v,r) -> + let r' = + filterRestrictions r settings.FrameworkRestrictions + |> filterRestrictions globalFrameworkRestrictions + (n,v,r')) let explored = { Name = packageDetails.Name Version = version Dependencies = restrictedDependencies Unlisted = packageDetails.Unlisted - Settings = settings.AdjustWithSpecialCases packageDetails.Name + Settings = settings Source = packageDetails.Source } exploredPackages.Add((dependency.Name,version),explored) explored diff --git a/src/Paket.Core/Requirements.fs b/src/Paket.Core/Requirements.fs index 1544eec8c7..903923d51e 100644 --- a/src/Paket.Core/Requirements.fs +++ b/src/Paket.Core/Requirements.fs @@ -85,7 +85,7 @@ let rec optimizeRestrictions restrictions = let newRestrictions' = restrictions |> List.distinct - |> List.sort + |> List.sort let newRestrictions = match newRestrictions' |> Seq.tryFind (function | FrameworkRestriction.AtLeast r -> true | _ -> false) with @@ -94,7 +94,7 @@ let rec optimizeRestrictions restrictions = let currentVersion = match r with | FrameworkRestriction.AtLeast(DotNetFramework(x)) -> x - | x -> failwithf "Unknown .NET moniker %O" x + | x -> failwithf "Unknown .NET moniker %O" x let isLowerVersion x = let isMatching x = @@ -115,7 +115,7 @@ let rec optimizeRestrictions restrictions = match n with | FrameworkRestriction.Exactly(DotNetFramework(x)) -> x | FrameworkRestriction.AtLeast(DotNetFramework(x)) -> x - | x -> failwithf "Unknown .NET moniker %O" x + | x -> failwithf "Unknown .NET moniker %O" x (newRestrictions' |> List.filter (fun x -> x <> r && x <> n)) @ [FrameworkRestriction.AtLeast(DotNetFramework(newLowest))] @@ -166,7 +166,7 @@ let optimizeDependencies packages = |> List.sort let localMaxDotNetRestriction = findMaxDotNetRestriction plain - let globalMax = defaultArg globalMax localMaxDotNetRestriction + let globalMax = defaultArg globalMax localMaxDotNetRestriction let dotnetRestrictions,others = List.partition (function | FrameworkRestriction.Exactly(DotNetFramework(_)) -> true | FrameworkRestriction.AtLeast(DotNetFramework(_)) -> true | _ -> false) plain @@ -174,7 +174,7 @@ let optimizeDependencies packages = dotnetRestrictions |> List.map (fun restriction -> match restriction with - | FrameworkRestriction.Exactly r -> + | FrameworkRestriction.Exactly r -> if r = localMaxDotNetRestriction && r = globalMax then FrameworkRestriction.AtLeast r else diff --git a/src/Paket/Paket.fsproj b/src/Paket/Paket.fsproj index 84145c490c..9224627923 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\i001166-resolve-nancy-fast\temp + D:\code\Paket\integrationtests\scenarios\i001182-framework-restrictions\temp pdbonly diff --git a/tests/Paket.Tests/Lockfile/GeneratorSpecs.fs b/tests/Paket.Tests/Lockfile/GeneratorSpecs.fs index 5c09397fdd..01dea9c85f 100644 --- a/tests/Paket.Tests/Lockfile/GeneratorSpecs.fs +++ b/tests/Paket.Tests/Lockfile/GeneratorSpecs.fs @@ -62,14 +62,14 @@ let ``should generate lock file with framework restrictions for packages``() = specs: Castle.Windsor (2.1) - framework: net35 Castle.Windsor-log4net (3.3) - framework: net35 - Castle.Windsor (>= 2.0) - log4net (>= 1.0) + Castle.Windsor (>= 2.0) - framework: net35 + log4net (>= 1.0) - framework: net35 log (1.2) - framework: net35 log4net (1.1) - framework: net35 - log (>= 1.0) + log (>= 1.0) - framework: net35 Rx-Core (2.1) - framework: >= net40 Rx-Main (2.0) - framework: >= net40 - Rx-Core (>= 2.1)""" + Rx-Core (>= 2.1) - framework: >= net40""" let cfg = DependenciesFile.FromCode(configWithRestrictions) ResolveWithGraph(cfg,noSha1,VersionsFromGraphAsSeq graph, PackageDetailsFromGraph graph).[Constants.MainDependencyGroup].ResolvedPackages.GetModelOrFail() @@ -90,14 +90,14 @@ let ``should generate lock file with no targets import for packages``() = specs: Castle.Windsor (2.1) - import_targets: false, framework: net35 Castle.Windsor-log4net (3.3) - import_targets: false, framework: net35 - Castle.Windsor (>= 2.0) - log4net (>= 1.0) + Castle.Windsor (>= 2.0) - framework: net35 + log4net (>= 1.0) - framework: net35 log (1.2) - import_targets: false, framework: net35 log4net (1.1) - import_targets: false, framework: net35 - log (>= 1.0) + log (>= 1.0) - framework: net35 Rx-Core (2.1) - framework: >= net40 Rx-Main (2.0) - framework: >= net40 - Rx-Core (>= 2.1)""" + Rx-Core (>= 2.1) - framework: >= net40""" let cfg = DependenciesFile.FromCode(configWithNoImport) ResolveWithGraph(cfg,noSha1,VersionsFromGraphAsSeq graph, PackageDetailsFromGraph graph).[Constants.MainDependencyGroup].ResolvedPackages.GetModelOrFail() @@ -117,14 +117,14 @@ let ``should generate lock file with no copy local for packages``() = specs: Castle.Windsor (2.1) - copy_local: false, import_targets: false, framework: net35 Castle.Windsor-log4net (3.3) - copy_local: false, import_targets: false, framework: net35 - Castle.Windsor (>= 2.0) - log4net (>= 1.0) + Castle.Windsor (>= 2.0) - framework: net35 + log4net (>= 1.0) - framework: net35 log (1.2) - copy_local: false, import_targets: false, framework: net35 log4net (1.1) - copy_local: false, import_targets: false, framework: net35 - log (>= 1.0) + log (>= 1.0) - framework: net35 Rx-Core (2.1) - framework: >= net40 Rx-Main (2.0) - framework: >= net40 - Rx-Core (>= 2.1)""" + Rx-Core (>= 2.1) - framework: >= net40""" let cfg = DependenciesFile.FromCode(configWithCopyLocal) ResolveWithGraph(cfg,noSha1,VersionsFromGraphAsSeq graph, PackageDetailsFromGraph graph).[Constants.MainDependencyGroup].ResolvedPackages.GetModelOrFail() |> LockFileSerializer.serializePackages cfg.Groups.[Constants.MainDependencyGroup].Options @@ -144,14 +144,14 @@ let ``should generate lock file with disabled content for packages``() = specs: Castle.Windsor (2.1) - framework: net35 Castle.Windsor-log4net (3.3) - framework: net35 - Castle.Windsor (>= 2.0) - log4net (>= 1.0) + Castle.Windsor (>= 2.0) - framework: net35 + log4net (>= 1.0) - framework: net35 log (1.2) - framework: net35 log4net (1.1) - framework: net35 - log (>= 1.0) + log (>= 1.0) - framework: net35 Rx-Core (2.1) - content: none, framework: >= net40 Rx-Main (2.0) - content: none, framework: >= net40 - Rx-Core (>= 2.1)""" + Rx-Core (>= 2.1) - framework: >= net40""" let cfg = DependenciesFile.FromCode(configWithDisabledContent) ResolveWithGraph(cfg,noSha1,VersionsFromGraphAsSeq graph, PackageDetailsFromGraph graph).[Constants.MainDependencyGroup].ResolvedPackages.GetModelOrFail() |> LockFileSerializer.serializePackages cfg.Groups.[Constants.MainDependencyGroup].Options