From 4de35165d8f4f54d60c8fdbddd6dafe49c62b03a Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Mon, 17 Apr 2017 14:58:14 +0200 Subject: [PATCH 01/30] add rid and graph parameters --- src/Paket.Core/InstallModel.fs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Paket.Core/InstallModel.fs b/src/Paket.Core/InstallModel.fs index 60d8bf570b..a0880dd76d 100644 --- a/src/Paket.Core/InstallModel.fs +++ b/src/Paket.Core/InstallModel.fs @@ -445,7 +445,7 @@ module InstallModel = getLegacyReferences target installModel else results - let getRuntimeLibraries (target : TargetProfile) (installModel:InstallModel) = + let getRuntimeLibraries graph rid (target : TargetProfile) (installModel:InstallModel) = getFileFolders target (installModel.RuntimeLibFolders) (function Reference.Library lib -> Some lib | _ -> None) |> Seq.cache @@ -730,7 +730,7 @@ type InstallModel with member this.GetLibReferences target = InstallModel.getLegacyReferences target this member this.GetLegacyReferences target = InstallModel.getLegacyReferences target this member this.GetCompileReferences target = InstallModel.getCompileReferences target this - member this.GetRuntimeLibraries target = InstallModel.getRuntimeLibraries target this + member this.GetRuntimeLibraries graph rid target = InstallModel.getRuntimeLibraries graph rid target this [] member this.GetLibReferences frameworkIdentifier = InstallModel.getLegacyPlatformReferences frameworkIdentifier this From b99bc0b2eae4f755e1c386d297767822f4fe8937 Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Mon, 17 Apr 2017 19:19:11 +0200 Subject: [PATCH 02/30] add parsing of the runtime graph --- src/Paket.Core/Paket.Core.fsproj | 1 + src/Paket.Core/RuntimeGraph.fs | 120 ++++++++++++++++++ .../InstallModel/ProcessingSpecs.fs | 4 +- tests/Paket.Tests/Paket.Tests.fsproj | 1 + tests/Paket.Tests/RuntimeGraphTests.fs | 98 ++++++++++++++ tests/Paket.Tests/paket.references | 1 + 6 files changed, 223 insertions(+), 2 deletions(-) create mode 100644 src/Paket.Core/RuntimeGraph.fs create mode 100644 tests/Paket.Tests/RuntimeGraphTests.fs diff --git a/src/Paket.Core/Paket.Core.fsproj b/src/Paket.Core/Paket.Core.fsproj index 900dca9d0b..3f52b61db8 100644 --- a/src/Paket.Core/Paket.Core.fsproj +++ b/src/Paket.Core/Paket.Core.fsproj @@ -112,6 +112,7 @@ + diff --git a/src/Paket.Core/RuntimeGraph.fs b/src/Paket.Core/RuntimeGraph.fs new file mode 100644 index 0000000000..8b542330bc --- /dev/null +++ b/src/Paket.Core/RuntimeGraph.fs @@ -0,0 +1,120 @@ +namespace Paket + +open Domain + +// See https://github.com/NuGet/NuGet.Client/blob/85731166154d0818d79a19a6d2417de6aa851f39/src/NuGet.Core/NuGet.Packaging/RuntimeModel/RuntimeGraph.cs +// See http://www.natemcmaster.com/blog/2016/05/19/nuget3-rid-graph/ + +// Example files can be found in the packages "Microsoft.NETCore.Platforms 1.1.0" and "Microsoft.NETCore.Targets 1.1.0" + +type Rid = + private { Rid : string } + static member Of s = { Rid = s } + static member Parse s = Rid.Of s + override x.ToString () = x.Rid + +type CompatibilityProfileName = string + +type CompatibilityProfile = + { Name : CompatibilityProfileName + Supported : Map } + +type RuntimeDescription = + { Rid : Rid + InheritedRids : Rid list + RuntimeDependencies : Map } + +type RuntimeGraph = + { Supports : Map + Runtimes : Map } + +open Newtonsoft.Json +open Newtonsoft.Json.Linq + +module RuntimeGraphParser = + open System.Collections.Generic + + (* +{ "uwp.10.0.app": { + "uap10.0": [ + "win10-x86", + "win10-x86-aot", + "win10-x64", + "win10-x64-aot", + "win10-arm", + "win10-arm-aot" + ] + } +}*) + let readCompatiblityProfilesJ (json:JObject) = + [ for t in json :> IEnumerable> do + yield + { Name = t.Key + Supported = + [ for s in t.Value :?> JObject :> IEnumerable> do + match FrameworkDetection.Extract s.Key with + | Some fid -> + yield fid, [ for rid in (s.Value :?> JArray) -> { Rid = string rid } ] + | None -> failwithf "could not detect framework-identifier '%s'" s.Key ] + |> Map.ofSeq } ] + (*{ + "win": { + "#import": [ "any" ] + "Microsoft.Win32.Primitives": { + "runtime.win.Microsoft.Win32.Primitives": "4.3.0" + },*) + let readRuntimeDescriptionJ (json:JObject) = + [ for t in json :> IEnumerable> do + let rid = { Rid = t.Key } + match t.Value with + | :? JObject as spec -> + let imports = + match spec.["#import"] with + | :? JArray as j -> [ for t in j -> { Rid = string t } ] + | null -> [] + | o -> failwithf "unknown stuff in '#import' value: %O" o + let dependencies = + spec :> IEnumerable> + |> Seq.filter (fun kv -> kv.Key <> "#import") + |> Seq.map (fun kv -> + let packageName = PackageName kv.Key + let depsSpec = + match kv.Value with + | :? JObject as deps -> + deps :> IEnumerable> + |> Seq.map (fun kv -> PackageName kv.Key, VersionRequirement.Parse (string kv.Value)) + |> Seq.toList + | _ -> failwithf "unknown stuff in runtime-dependency: %O" kv.Value + packageName, depsSpec) + |> Map.ofSeq + yield + { Rid = rid + InheritedRids = imports + RuntimeDependencies = dependencies } + | _ -> failwithf "unknwn stuff in runtime-description: %O" t.Value ] + + let readRuntimeGraphJ (json:JObject) = + { Supports = + match json.["supports"] with + | :? JObject as supports -> + readCompatiblityProfilesJ supports + |> Seq.map (fun c -> c.Name, c) + |> Map.ofSeq + | null -> Map.empty + | _ -> failwith "invalid data in supports field." + Runtimes = + match json.["runtimes"] with + | :? JObject as runtimes -> + readRuntimeDescriptionJ runtimes + |> Seq.map (fun r -> r.Rid, r) + |> Map.ofSeq + | null -> Map.empty + | _ -> failwith "invalid data in runtimes" } + + let readRuntimeGraph (s:string) = + readRuntimeGraphJ (JObject.Parse(s)) + +module RuntimeGraph = + let read json = + () + diff --git a/tests/Paket.Tests/InstallModel/ProcessingSpecs.fs b/tests/Paket.Tests/InstallModel/ProcessingSpecs.fs index a6cdb13154..cd9266cbe7 100644 --- a/tests/Paket.Tests/InstallModel/ProcessingSpecs.fs +++ b/tests/Paket.Tests/InstallModel/ProcessingSpecs.fs @@ -112,12 +112,12 @@ let ``should understand reference folder``() = refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\lib\netstandard1.6\System.Security.Cryptography.Algorithms.dll" refs |> shouldContain @"..\System.Security.Cryptography.Algorithms\ref\netstandard1.6\System.Security.Cryptography.Algorithms.dll" - let refs = model.GetRuntimeLibraries(SinglePlatform (DotNetStandard DotNetStandardVersion.V1_6)) + let refs = model.GetRuntimeLibraries null null (SinglePlatform (DotNetStandard DotNetStandardVersion.V1_6)) refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\runtimes\win\lib\net46\System.Security.Cryptography.Algorithms.dll" refs |> shouldContain @"..\System.Security.Cryptography.Algorithms\lib\netstandard1.6\System.Security.Cryptography.Algorithms.dll" refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\ref\netstandard1.6\System.Security.Cryptography.Algorithms.dll" - let refs = model.GetRuntimeLibraries(SinglePlatform (DotNetFramework FrameworkVersion.V4_6_3)) + let refs = model.GetRuntimeLibraries null null(SinglePlatform (DotNetFramework FrameworkVersion.V4_6_3)) refs |> shouldContain @"..\System.Security.Cryptography.Algorithms\runtimes\win\lib\net46\System.Security.Cryptography.Algorithms.dll" // TODO: This is kind of broken for now -> the correct results depends on the runtime we want to get the runtime libraries for // therefore GetRuntimeLibraries needs an additional parameter... diff --git a/tests/Paket.Tests/Paket.Tests.fsproj b/tests/Paket.Tests/Paket.Tests.fsproj index 3c3d80f227..e7b87c66f8 100644 --- a/tests/Paket.Tests/Paket.Tests.fsproj +++ b/tests/Paket.Tests/Paket.Tests.fsproj @@ -364,6 +364,7 @@ + diff --git a/tests/Paket.Tests/RuntimeGraphTests.fs b/tests/Paket.Tests/RuntimeGraphTests.fs new file mode 100644 index 0000000000..decf7c443a --- /dev/null +++ b/tests/Paket.Tests/RuntimeGraphTests.fs @@ -0,0 +1,98 @@ +module Paket.RuntimeGraphTests + +open Paket +open NUnit.Framework +open FsUnit +open Paket.Domain + +let supportAndDeps = """ +{ + "runtimes": { + "win": { + "Microsoft.Win32.Primitives": { + "runtime.win.Microsoft.Win32.Primitives": "4.3.0" + }, + "System.Runtime.Extensions": { + "runtime.win.System.Runtime.Extensions": "4.3.0" + } + } + }, + "supports": { + "uwp.10.0.app": { + "uap10.0": [ + "win10-x86", + "win10-x86-aot", + "win10-arm", + "win10-arm-aot" + ] + }, + "net45.app": { + "net45": [ + "", + "win-x86", + "win-x64" + ] + } + } +}""" + + +let rids = """ +{ + "runtimes": { + "base": { + }, + "any": { + "#import": [ "base" ] + }, + "win": { + "#import": [ "any" ] + } + } +} +""" + +[] +let ``Check if we can parse runtime support and runtime dependencies``() = + let runtimeGraph = RuntimeGraphParser.readRuntimeGraph supportAndDeps + + runtimeGraph + |> shouldEqual + { Runtimes = + [ { Rid = Rid.Of "win"; InheritedRids = [ ] + RuntimeDependencies = + [ PackageName "Microsoft.Win32.Primitives", [ PackageName "runtime.win.Microsoft.Win32.Primitives", VersionRequirement.VersionRequirement (VersionRange.Minimum (SemVer.Parse "4.3.0"), PreReleaseStatus.No) ] + PackageName "System.Runtime.Extensions", [ PackageName "runtime.win.System.Runtime.Extensions", VersionRequirement.VersionRequirement (VersionRange.Minimum (SemVer.Parse "4.3.0"), PreReleaseStatus.No) ] + ] + |> Map.ofSeq } ] + |> Seq.map (fun r -> r.Rid, r) + |> Map.ofSeq + Supports = + [ { Name = "net45.app" + Supported = + [ FrameworkIdentifier.DotNetFramework FrameworkVersion.V4_5, [ Rid.Of ""; Rid.Of "win-x86"; Rid.Of "win-x64" ]] + |> Map.ofSeq } + { Name = "uwp.10.0.app" + Supported = + [ FrameworkIdentifier.UAP UAPVersion.V10, [ Rid.Of "win10-x86"; Rid.Of "win10-x86-aot"; Rid.Of "win10-arm"; Rid.Of "win10-arm-aot" ]] + |> Map.ofSeq } ] + |> Seq.map (fun c -> c.Name, c) + |> Map.ofSeq + } + +[] +let ``Check if we can parse runtime rids``() = + let runtimeGraph = RuntimeGraphParser.readRuntimeGraph rids + + runtimeGraph + |> shouldEqual + { Runtimes = + [ { Rid = Rid.Of "base"; InheritedRids = [ ]; RuntimeDependencies = Map.empty } + { Rid = Rid.Of "any"; InheritedRids = [ Rid.Of "base" ]; RuntimeDependencies = Map.empty } + { Rid = Rid.Of "win"; InheritedRids = [ Rid.Of "any" ]; RuntimeDependencies = Map.empty } ] + |> Seq.map (fun r -> r.Rid, r) + |> Map.ofSeq + Supports = + [] + |> Map.ofSeq + } \ No newline at end of file diff --git a/tests/Paket.Tests/paket.references b/tests/Paket.Tests/paket.references index ccb5bb978f..b67b69b831 100644 --- a/tests/Paket.Tests/paket.references +++ b/tests/Paket.Tests/paket.references @@ -1,6 +1,7 @@ FSharp.Core Chessie + group Test NUnit NUnit3TestAdapter From e916e0d5730391a91df08ec2664aed9866763ba3 Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Mon, 17 Apr 2017 20:06:13 +0200 Subject: [PATCH 03/30] implement merge --- src/Paket.Core/RuntimeGraph.fs | 33 +++++++++++++++++++++++--- tests/Paket.Tests/RuntimeGraphTests.fs | 16 ++++++++++++- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/src/Paket.Core/RuntimeGraph.fs b/src/Paket.Core/RuntimeGraph.fs index 8b542330bc..20aff75381 100644 --- a/src/Paket.Core/RuntimeGraph.fs +++ b/src/Paket.Core/RuntimeGraph.fs @@ -34,7 +34,7 @@ open Newtonsoft.Json.Linq module RuntimeGraphParser = open System.Collections.Generic - (* + (* { "uwp.10.0.app": { "uap10.0": [ "win10-x86", @@ -114,7 +114,34 @@ module RuntimeGraphParser = let readRuntimeGraph (s:string) = readRuntimeGraphJ (JObject.Parse(s)) +module Map = + let merge (f:'b -> 'b -> 'b) (m1:Map<'a,'b>) (m2:Map<'a,'b>) = + m1 + |> Map.toSeq + |> Seq.append (m2 |> Map.toSeq) + |> Seq.groupBy (fst) + |> Seq.map (fun (k, g) -> + match g |> Seq.map snd |> Seq.toList with + | [ a; b ] -> k, f a b + | [ a ] -> k, a + | _ -> failwithf "This should never happen") + |> Map.ofSeq + module RuntimeGraph = - let read json = - () + let mergeCompatibility (s1:CompatibilityProfile) (s2:CompatibilityProfile) = + assert (s1.Name = s2.Name) + { Name = s1.Name + Supported = + Map.merge (@) s1.Supported s2.Supported + |> Map.map (fun _ l -> List.distinct l) } + let mergeDescription (d1:RuntimeDescription) (d2:RuntimeDescription) = + assert (d1.Rid = d2.Rid) + { Rid = d1.Rid + InheritedRids = d1.InheritedRids @ d2.InheritedRids |> List.distinct + RuntimeDependencies = + Map.merge (@) d1.RuntimeDependencies d2.RuntimeDependencies + |> Map.map (fun _ l -> List.distinct l) } + let merge (r1:RuntimeGraph) (r2:RuntimeGraph) = + { Supports = Map.merge mergeCompatibility r1.Supports r2.Supports + Runtimes = Map.merge mergeDescription r1.Runtimes r2.Runtimes } diff --git a/tests/Paket.Tests/RuntimeGraphTests.fs b/tests/Paket.Tests/RuntimeGraphTests.fs index decf7c443a..966ac72f02 100644 --- a/tests/Paket.Tests/RuntimeGraphTests.fs +++ b/tests/Paket.Tests/RuntimeGraphTests.fs @@ -95,4 +95,18 @@ let ``Check if we can parse runtime rids``() = Supports = [] |> Map.ofSeq - } \ No newline at end of file + } + +[] +let ``Check if we can merge two graphs``() = + let r1 = RuntimeGraphParser.readRuntimeGraph rids + let r2 = RuntimeGraphParser.readRuntimeGraph supportAndDeps + let merged = RuntimeGraph.merge r1 r2 + let win = merged.Runtimes.[Rid.Of "win"] + win.InheritedRids + |> shouldEqual [ Rid.Of "any" ] + win.RuntimeDependencies + |> shouldEqual + ([ PackageName "Microsoft.Win32.Primitives", [ PackageName "runtime.win.Microsoft.Win32.Primitives", VersionRequirement.VersionRequirement (VersionRange.Minimum (SemVer.Parse "4.3.0"), PreReleaseStatus.No) ] + PackageName "System.Runtime.Extensions", [ PackageName "runtime.win.System.Runtime.Extensions", VersionRequirement.VersionRequirement (VersionRange.Minimum (SemVer.Parse "4.3.0"), PreReleaseStatus.No) ] + ] |> Map.ofSeq) \ No newline at end of file From 25e4c4a18883a8869603f31ff24f5d7c409b64a6 Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Mon, 17 Apr 2017 20:09:38 +0200 Subject: [PATCH 04/30] add newtonsoft json dep to unit test project --- .paket/Paket.Restore.targets | 6 +- tests/Paket.Tests/Paket.Tests.fsproj | 569 ++++++++++++++++++++------- tests/Paket.Tests/paket.references | 2 +- 3 files changed, 422 insertions(+), 155 deletions(-) diff --git a/.paket/Paket.Restore.targets b/.paket/Paket.Restore.targets index ebcce7ffa6..e48e078d65 100644 --- a/.paket/Paket.Restore.targets +++ b/.paket/Paket.Restore.targets @@ -45,7 +45,7 @@ false - + $(MSBuildProjectDirectory)/obj/$(MSBuildProjectFile).references @@ -57,11 +57,11 @@ - + - + + + + + + ..\..\packages\Microsoft.CSharp\ref\netstandard1.0\Microsoft.CSharp.dll + False + True + + + + + + + ..\..\packages\Microsoft.CSharp\lib\netstandard1.3\Microsoft.CSharp.dll + True + True + + + + + + + + + ..\..\packages\Newtonsoft.Json\lib\net20\Newtonsoft.Json.dll + True + True + + + + + + + ..\..\packages\Newtonsoft.Json\lib\net35\Newtonsoft.Json.dll + True + True + + + + + + + ..\..\packages\Newtonsoft.Json\lib\net40\Newtonsoft.Json.dll + True + True + + + + + + + ..\..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll + True + True + + + + + + + ..\..\packages\Newtonsoft.Json\lib\netstandard1.0\Newtonsoft.Json.dll + True + True + + + + + + + ..\..\packages\Newtonsoft.Json\lib\netstandard1.3\Newtonsoft.Json.dll + True + True + + + + + + + ..\..\packages\Newtonsoft.Json\lib\portable-net45+win8+wpa81+wp8\Newtonsoft.Json.dll + True + True + + + + @@ -510,6 +595,79 @@ + + + + + ..\..\packages\System.Collections.NonGeneric\lib\netstandard1.3\System.Collections.NonGeneric.dll + True + True + + + + + + + + + ..\..\packages\System.Collections.Specialized\lib\netstandard1.3\System.Collections.Specialized.dll + True + True + + + + + + + + + ..\..\packages\System.ComponentModel\ref\netstandard1.0\System.ComponentModel.dll + False + True + + + + + + + ..\..\packages\System.ComponentModel\lib\netstandard1.3\System.ComponentModel.dll + True + True + + + + + + + + + ..\..\packages\System.ComponentModel.Primitives\lib\netstandard1.0\System.ComponentModel.Primitives.dll + True + True + + + + + + + + + ..\..\packages\System.ComponentModel.TypeConverter\lib\netstandard1.0\System.ComponentModel.TypeConverter.dll + True + True + + + + + + + ..\..\packages\System.ComponentModel.TypeConverter\lib\netstandard1.5\System.ComponentModel.TypeConverter.dll + True + True + + + + @@ -541,6 +699,26 @@ + + + + + ..\..\packages\System.Dynamic.Runtime\ref\netstandard1.0\System.Dynamic.Runtime.dll + False + True + + + + + + + ..\..\packages\System.Dynamic.Runtime\lib\netstandard1.3\System.Dynamic.Runtime.dll + True + True + + + + @@ -561,6 +739,17 @@ + + + + + ..\..\packages\System.Globalization.Extensions\ref\netstandard1.3\System.Globalization.Extensions.dll + False + True + + + + @@ -599,6 +788,46 @@ + + + + + ..\..\packages\System.IO.FileSystem\lib\net46\System.IO.FileSystem.dll + True + True + + + + + + + ..\..\packages\System.IO.FileSystem\ref\netstandard1.3\System.IO.FileSystem.dll + False + True + + + + + + + + + ..\..\packages\System.IO.FileSystem.Primitives\lib\net46\System.IO.FileSystem.Primitives.dll + True + True + + + + + + + ..\..\packages\System.IO.FileSystem.Primitives\lib\netstandard1.3\System.IO.FileSystem.Primitives.dll + True + True + + + + @@ -887,6 +1116,55 @@ + + + + + ..\..\packages\System.Runtime.Handles\ref\netstandard1.3\System.Runtime.Handles.dll + False + True + + + + + + + + + ..\..\packages\System.Runtime.InteropServices\lib\net462\System.Runtime.InteropServices.dll + True + True + + + + + + + ..\..\packages\System.Runtime.InteropServices\lib\net463\System.Runtime.InteropServices.dll + True + True + + + + + + + ..\..\packages\System.Runtime.InteropServices\ref\netstandard1.3\System.Runtime.InteropServices.dll + False + True + + + + + + + ..\..\packages\System.Runtime.InteropServices\ref\netstandard1.5\System.Runtime.InteropServices.dll + False + True + + + + @@ -898,6 +1176,46 @@ + + + + + ..\..\packages\System.Runtime.Serialization.Formatters\ref\netstandard1.3\System.Runtime.Serialization.Formatters.dll + False + True + + + + + + + ..\..\packages\System.Runtime.Serialization.Formatters\lib\netstandard1.4\System.Runtime.Serialization.Formatters.dll + True + True + + + + + + + + + ..\..\packages\System.Runtime.Serialization.Primitives\ref\netstandard1.0\System.Runtime.Serialization.Primitives.dll + False + True + + + + + + + ..\..\packages\System.Runtime.Serialization.Primitives\lib\netstandard1.3\System.Runtime.Serialization.Primitives.dll + True + True + + + + @@ -918,6 +1236,26 @@ + + + + + ..\..\packages\System.Text.Encoding.Extensions\ref\netstandard1.0\System.Text.Encoding.Extensions.dll + False + True + + + + + + + ..\..\packages\System.Text.Encoding.Extensions\ref\netstandard1.3\System.Text.Encoding.Extensions.dll + False + True + + + + @@ -996,6 +1334,17 @@ + + + + + ..\..\packages\System.Threading.Tasks.Extensions\lib\netstandard1.0\System.Threading.Tasks.Extensions.dll + True + True + + + + @@ -1049,6 +1398,75 @@ + + + + + ..\..\packages\System.Xml.ReaderWriter\lib\net46\System.Xml.ReaderWriter.dll + True + True + + + + + + + ..\..\packages\System.Xml.ReaderWriter\ref\netstandard1.0\System.Xml.ReaderWriter.dll + False + True + + + + + + + ..\..\packages\System.Xml.ReaderWriter\lib\netstandard1.3\System.Xml.ReaderWriter.dll + True + True + + + + + + + + + ..\..\packages\System.Xml.XDocument\ref\netstandard1.0\System.Xml.XDocument.dll + False + True + + + + + + + ..\..\packages\System.Xml.XDocument\lib\netstandard1.3\System.Xml.XDocument.dll + True + True + + + + + + + + + ..\..\packages\System.Xml.XmlDocument\lib\net46\System.Xml.XmlDocument.dll + True + True + + + + + + + ..\..\packages\System.Xml.XmlDocument\lib\netstandard1.3\System.Xml.XmlDocument.dll + True + True + + + + @@ -1315,26 +1733,6 @@ - - - - - ..\..\packages\test\System.Globalization.Extensions\lib\net46\System.Globalization.Extensions.dll - True - True - - - - - - - ..\..\packages\test\System.Globalization.Extensions\ref\netstandard1.3\System.Globalization.Extensions.dll - False - True - - - - @@ -1369,46 +1767,6 @@ - - - - - ..\..\packages\test\System.IO.FileSystem\lib\net46\System.IO.FileSystem.dll - True - True - - - - - - - ..\..\packages\test\System.IO.FileSystem\ref\netstandard1.3\System.IO.FileSystem.dll - False - True - - - - - - - - - ..\..\packages\test\System.IO.FileSystem.Primitives\lib\net46\System.IO.FileSystem.Primitives.dll - True - True - - - - - - - ..\..\packages\test\System.IO.FileSystem.Primitives\lib\netstandard1.3\System.IO.FileSystem.Primitives.dll - True - True - - - - @@ -1451,55 +1809,6 @@ - - - - - ..\..\packages\test\System.Runtime.Handles\ref\netstandard1.3\System.Runtime.Handles.dll - False - True - - - - - - - - - ..\..\packages\test\System.Runtime.InteropServices\lib\net462\System.Runtime.InteropServices.dll - True - True - - - - - - - ..\..\packages\test\System.Runtime.InteropServices\lib\net463\System.Runtime.InteropServices.dll - True - True - - - - - - - ..\..\packages\test\System.Runtime.InteropServices\ref\netstandard1.3\System.Runtime.InteropServices.dll - False - True - - - - - - - ..\..\packages\test\System.Runtime.InteropServices\ref\netstandard1.5\System.Runtime.InteropServices.dll - False - True - - - - @@ -1680,46 +1989,4 @@ - - - - - ..\..\packages\test\System.Threading.Tasks.Extensions\lib\netstandard1.0\System.Threading.Tasks.Extensions.dll - True - True - - - - - - - - - ..\..\packages\test\System.Xml.ReaderWriter\lib\net46\System.Xml.ReaderWriter.dll - True - True - - - - - - - ..\..\packages\test\System.Xml.ReaderWriter\lib\netstandard1.3\System.Xml.ReaderWriter.dll - True - True - - - - - - - - - ..\..\packages\test\System.Xml.XDocument\lib\netstandard1.3\System.Xml.XDocument.dll - True - True - - - - \ No newline at end of file diff --git a/tests/Paket.Tests/paket.references b/tests/Paket.Tests/paket.references index b67b69b831..b458beeccc 100644 --- a/tests/Paket.Tests/paket.references +++ b/tests/Paket.Tests/paket.references @@ -1,6 +1,6 @@ FSharp.Core Chessie - +Newtonsoft.Json group Test NUnit From 2db9f1f5fbd728ae2e27f34eb2dc4feff8e637a5 Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Mon, 17 Apr 2017 20:18:17 +0200 Subject: [PATCH 05/30] use vs2017 image for F# 4.1 support --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index ddfb115642..4bab5e2a36 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,3 +1,4 @@ +image: Visual Studio 2017 init: - git config --global core.autocrlf input build_script: From 51a476896d541e6b4e88d4acfcd6aa71a5f4c94a Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Mon, 17 Apr 2017 20:19:55 +0200 Subject: [PATCH 06/30] use F#4.1 for paket.core --- src/Paket.Core/Paket.Core.fsproj | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Paket.Core/Paket.Core.fsproj b/src/Paket.Core/Paket.Core.fsproj index 3f52b61db8..17e36fb5c2 100644 --- a/src/Paket.Core/Paket.Core.fsproj +++ b/src/Paket.Core/Paket.Core.fsproj @@ -9,7 +9,7 @@ Paket Paket.Core v4.5 - 4.4.0.0 + 4.4.1.0 Paket ..\..\ @@ -63,6 +63,11 @@ $(MSBuildProgramFiles32)\Microsoft SDKs\F#\4.0\Framework\v4.0\Microsoft.FSharp.Targets + + + $(MSBuildProgramFiles32)\Microsoft SDKs\F#\4.1\Framework\v4.0\Microsoft.FSharp.Targets + + $(MSBuildProgramFiles32)\Microsoft SDKs\F#\4.1\Framework\v4.0\Microsoft.FSharp.Targets From deb17ce03223dee52466197e26d192255981e9e3 Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Mon, 17 Apr 2017 22:59:22 +0200 Subject: [PATCH 07/30] commit what I have for now --- src/Paket.Core/Queries.fs | 26 +++++++++++++++++++++++ src/Paket.Core/RuntimeGraph.fs | 38 ++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/src/Paket.Core/Queries.fs b/src/Paket.Core/Queries.fs index b9a18a66a2..c67407592e 100644 --- a/src/Paket.Core/Queries.fs +++ b/src/Paket.Core/Queries.fs @@ -75,6 +75,32 @@ let getInstalledPackageModel (lockFile: LockFile) (QualifiedPackageName(groupNam let files = NuGetV2.GetLibFiles(folder.FullName) InstallModel.CreateFromLibs(packageName, resolvedPackage.Version, [], files, [], [], nuspec) +let getRuntimeGraph (lockFile: LockFile) (groupName:GroupName) = + lockFile.Groups + |> Map.tryFind groupName + |> Option.toList + |> Seq.collect (fun group -> group.Resolution |> Map.toSeq) + |> Seq.map snd + |> Seq.choose (fun p -> + let groupFolder = if groupName = Constants.MainDependencyGroup then "" else "/" + groupName.ToString() + let runtimeJson = sprintf "%s/packages%s/%O/runtime.json" lockFile.RootPath groupFolder p.Name + if File.Exists runtimeJson then Some runtimeJson + else None) + |> Seq.map File.ReadAllText + |> Seq.map RuntimeGraphParser.readRuntimeGraph + |> RuntimeGraph.mergeSeq + +let getRuntimePackages (rid) (lockFile:LockFile) (groupName:GroupName) = + let g = getRuntimeGraph lockFile groupName + + lockFile.Groups + |> Map.tryFind groupName + |> Option.toList + |> Seq.collect (fun group -> group.Resolution |> Map.toSeq) + |> Seq.map snd + |> Seq.collect (fun p -> RuntimeGraph.findRuntimeDependencies rid p.Name g) + |> Seq.toList + let resolveFrameworkForScriptGeneration (dependencies: DependenciesFile) = lazy ( dependencies.Groups |> Seq.map (fun f -> f.Value.Options.Settings.FrameworkRestrictions) diff --git a/src/Paket.Core/RuntimeGraph.fs b/src/Paket.Core/RuntimeGraph.fs index 20aff75381..b9c4b36a48 100644 --- a/src/Paket.Core/RuntimeGraph.fs +++ b/src/Paket.Core/RuntimeGraph.fs @@ -27,6 +27,7 @@ type RuntimeDescription = type RuntimeGraph = { Supports : Map Runtimes : Map } + static member Empty = { Supports = Map.empty; Runtimes = Map.empty } open Newtonsoft.Json open Newtonsoft.Json.Linq @@ -145,3 +146,40 @@ module RuntimeGraph = { Supports = Map.merge mergeCompatibility r1.Supports r2.Supports Runtimes = Map.merge mergeDescription r1.Runtimes r2.Runtimes } + let mergeSeq s = + s |> Seq.fold merge RuntimeGraph.Empty + + let getInheritanceList (rid:Rid) (g:RuntimeGraph) = + let rec getListRec currentList toInspect = + match toInspect with + | rid :: rest -> + if List.contains rid currentList then + getListRec currentList rest + else + let desc = g.Runtimes.[rid] + let filtered = desc.InheritedRids |> List.filter (fun inh -> not (List.contains inh currentList)) + let newList = currentList @ filtered + let toInspect = rest @ filtered + getListRec newList toInspect + | _ -> currentList + + getListRec [rid] [rid] + + let getKnownRids (g:RuntimeGraph) = + g.Runtimes |> Map.toSeq |> Seq.map fst + + let areCompatible projectRid assetRid g = + g + |> getInheritanceList projectRid + |> List.contains assetRid + + let findRuntimeDependencies rid packageName g = + getInheritanceList rid g + |> Seq.choose (fun r -> + match g.Runtimes |> Map.tryFind r with + | Some desc -> + desc.RuntimeDependencies |> Map.tryFind packageName + | None -> None) + |> Seq.tryHead + |> Option.defaultValue [] + From 554a503aaeaf4db3954dcda1a557fa9534537a71 Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Tue, 18 Apr 2017 12:57:58 +0200 Subject: [PATCH 08/30] commit the current idea --- src/Paket.Core/Files/DependenciesFile.fs | 55 ++++++++++++++++++++++++ src/Paket.Core/PackageResolver.fs | 26 +++++------ src/Paket.Core/Paket.Core.fsproj | 6 +-- 3 files changed, 72 insertions(+), 15 deletions(-) diff --git a/src/Paket.Core/Files/DependenciesFile.fs b/src/Paket.Core/Files/DependenciesFile.fs index acfaa41e3c..23691f1400 100644 --- a/src/Paket.Core/Files/DependenciesFile.fs +++ b/src/Paket.Core/Files/DependenciesFile.fs @@ -201,6 +201,7 @@ type DependenciesFile(fileName,groups:Map, textRepr if String.IsNullOrWhiteSpace fileName |> not then RemoteDownload.DownloadSourceFiles(Path.GetDirectoryName fileName, groupName, force, remoteFiles) + // Step 1 Package resolution let resolution = PackageResolver.Resolve( getVersionF, @@ -212,6 +213,60 @@ type DependenciesFile(fileName,groups:Map, textRepr remoteDependencies @ group.Packages |> Set.ofList, updateMode) + // Step 2 Runtime package resolution, see https://github.com/fsprojects/Paket/pull/2255 + let runtimeResolution = + match resolution with + | Resolution.Ok resolved -> + // runtime resolution step + let runtimeGraph = + resolved + |> Map.toSeq |> Seq.map snd + // 1. downloading packages into cache + |> Seq.map (fun package -> package, NuGetV2.DownloadPackage (None, "C:\FakeRoot", package.Source, [], groupName, package.Name, package.Version, false, false, false) |> Async.RunSynchronously) + |> Seq.map (fun (p, (targetFileName, _)) -> p,targetFileName) + |> Seq.map (fun (package, t) -> package, NuGetV2.ExtractPackageToUserFolder (t, package.Name, package.Version, null) |> Async.RunSynchronously) + // 2. Get runtime graph + |> Seq.choose (fun (package, extracted) -> + let runtime = Path.Combine(extracted, "runtime.json") + if File.Exists runtime then Some (runtime) else None) + |> Seq.map RuntimeGraphParser.readRuntimeGraph + |> RuntimeGraph.mergeSeq + // 3. Resolve runtime deps and add it to the resolution + let rids = RuntimeGraph.getKnownRids runtimeGraph + let runtimeDeps = + resolved + |> Map.toSeq |> Seq.map snd + |> Seq.collect (fun p -> + rids + |> Seq.collect(fun rid -> RuntimeGraph.findRuntimeDependencies rid p.Name runtimeGraph)) + |> Seq.map (fun (name, versionReq) -> + { Name = name + VersionRequirement = versionReq + ResolverStrategyForDirectDependencies = Some ResolverStrategy.Max + ResolverStrategyForTransitives = Some ResolverStrategy.Max + Parent = PackageRequirementSource.DependenciesFile fileName + Graph = [] + Sources = group.Sources + Settings = group.Options.Settings }) + |> Seq.toList + + let runtimeResolution = + PackageResolver.Resolve( + getVersionF, + getPackageDetailsF, + groupName, + group.Options.ResolverStrategyForDirectDependencies, + group.Options.ResolverStrategyForTransitives, + group.Options.Settings.FrameworkRestrictions, + runtimeDeps |> Set.ofList, + updateMode) + + // Combine with existing resolution and mark runtime packages. + // Warn if a package is part of both resolutions + // Warn if a runtime package contains a runtime.json + resolution + | Resolution.Conflict _ -> resolution + { ResolvedPackages = resolution ResolvedSourceFiles = remoteFiles } diff --git a/src/Paket.Core/PackageResolver.fs b/src/Paket.Core/PackageResolver.fs index 084ee2e4da..decf5a4caa 100644 --- a/src/Paket.Core/PackageResolver.fs +++ b/src/Paket.Core/PackageResolver.fs @@ -70,12 +70,13 @@ type PackageDetails = { /// Represents data about resolved packages [] type ResolvedPackage = { - Name : PackageName - Version : SemVerInfo - Dependencies : DependencySet - Unlisted : bool - Settings : InstallSettings - Source : PackageSource + Name : PackageName + Version : SemVerInfo + Dependencies : DependencySet + Unlisted : bool + IsRuntimeDependency : bool + Settings : InstallSettings + Source : PackageSource } with override this.ToString () = sprintf "%O %O" this.Name this.Version @@ -377,12 +378,13 @@ let private explorePackageConfig getPackageDetailsF (pkgConfig:PackageConfig) = | _ -> dependency.Settings |> fun x -> x.AdjustWithSpecialCases packageDetails.Name Some - { Name = packageDetails.Name - Version = version - Dependencies = filteredDependencies - Unlisted = packageDetails.Unlisted - Settings = { settings with FrameworkRestrictions = newRestrictions } - Source = packageDetails.Source + { Name = packageDetails.Name + Version = version + Dependencies = filteredDependencies + Unlisted = packageDetails.Unlisted + Settings = { settings with FrameworkRestrictions = newRestrictions } + Source = packageDetails.Source + IsRuntimeDependency = false } with | exn -> diff --git a/src/Paket.Core/Paket.Core.fsproj b/src/Paket.Core/Paket.Core.fsproj index 17e36fb5c2..6c60279ead 100644 --- a/src/Paket.Core/Paket.Core.fsproj +++ b/src/Paket.Core/Paket.Core.fsproj @@ -121,6 +121,9 @@ + + + @@ -128,9 +131,6 @@ - - - From 898d42eac354f2671c7925cbcea01393fcc0ccba Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Tue, 18 Apr 2017 13:16:51 +0200 Subject: [PATCH 09/30] combine resolutions --- src/Paket.Core/Files/DependenciesFile.fs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Paket.Core/Files/DependenciesFile.fs b/src/Paket.Core/Files/DependenciesFile.fs index 23691f1400..e384a6bef9 100644 --- a/src/Paket.Core/Files/DependenciesFile.fs +++ b/src/Paket.Core/Files/DependenciesFile.fs @@ -262,9 +262,16 @@ type DependenciesFile(fileName,groups:Map, textRepr updateMode) // Combine with existing resolution and mark runtime packages. - // Warn if a package is part of both resolutions - // Warn if a runtime package contains a runtime.json - resolution + // TODO: Warn if a package is part of both resolutions? + // TODO: Warn if a runtime package contains a runtime.json? -> We don't download them here :/ + match resolution with + | Resolution.Ok runtimeResolved -> + let mapped = + runtimeResolved + |> Map.map (fun _ v -> { v with IsRuntimeDependency = true }) + Map.merge (fun p1 p2 -> failwithf "same package '%A' in runtime and regular resolution" p1) resolved mapped + |> Resolution.Ok + | _ -> resolution | Resolution.Conflict _ -> resolution { ResolvedPackages = resolution From 4b0c41188db0ffe9c9b4faec2921f84304096baf Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Tue, 18 Apr 2017 13:25:06 +0200 Subject: [PATCH 10/30] make it build on netcore as well --- src/Paket.Core.preview3/Paket.Core.fsproj | 7 ++++--- src/Paket.Core/Files/LockFile.fs | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Paket.Core.preview3/Paket.Core.fsproj b/src/Paket.Core.preview3/Paket.Core.fsproj index 2eedbcb96a..828f055ffd 100644 --- a/src/Paket.Core.preview3/Paket.Core.fsproj +++ b/src/Paket.Core.preview3/Paket.Core.fsproj @@ -39,9 +39,13 @@ + + + + @@ -49,9 +53,6 @@ - - - diff --git a/src/Paket.Core/Files/LockFile.fs b/src/Paket.Core/Files/LockFile.fs index b80181b811..bc0c3e5fec 100644 --- a/src/Paket.Core/Files/LockFile.fs +++ b/src/Paket.Core/Files/LockFile.fs @@ -409,7 +409,9 @@ module LockFileParser = Dependencies = Set.empty Unlisted = false Settings = settings - Version = SemVer.Parse version } :: currentGroup.Packages }::otherGroups + Version = SemVer.Parse version + // TODO: write stuff into the lockfile and read it here + IsRuntimeDependency = false } :: currentGroup.Packages }::otherGroups | None -> failwith "no source has been specified." | NugetDependency (name, v, frameworkSettings) -> let version,settings = parsePackage v From 320151f3bb553dd7ecb2c153442ea75c6935da12 Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Tue, 18 Apr 2017 13:28:05 +0200 Subject: [PATCH 11/30] fix build of test projects --- tests/Paket.Tests/Resolver/PropertyTests.fs | 3 ++- tests/Paket.Tests/ScriptGeneration/LoadingScriptTests.fs | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/Paket.Tests/Resolver/PropertyTests.fs b/tests/Paket.Tests/Resolver/PropertyTests.fs index 12fe12f500..f984625142 100644 --- a/tests/Paket.Tests/Resolver/PropertyTests.fs +++ b/tests/Paket.Tests/Resolver/PropertyTests.fs @@ -67,7 +67,8 @@ let bruteForce ((g,deps):ResolverPuzzle) = Dependencies = Set.empty Unlisted = false Settings = InstallSettings.Default - Source = PackageSources.DefaultNuGetSource } + Source = PackageSources.DefaultNuGetSource + IsRuntimeDependency = false } let deps' = packageDeps @ deps if createsError (g,deps') resolved then None else diff --git a/tests/Paket.Tests/ScriptGeneration/LoadingScriptTests.fs b/tests/Paket.Tests/ScriptGeneration/LoadingScriptTests.fs index c2e8ff73d4..29c5cfde83 100644 --- a/tests/Paket.Tests/ScriptGeneration/LoadingScriptTests.fs +++ b/tests/Paket.Tests/ScriptGeneration/LoadingScriptTests.fs @@ -19,13 +19,15 @@ let testData = Paket.Requirements.FrameworkRestrictions.AutoDetectFramework) PackageResolver.ResolvedPackage.Unlisted = false PackageResolver.ResolvedPackage.Settings = Requirements.InstallSettings.Default - PackageResolver.ResolvedPackage.Source = PackageSources.PackageSource.NuGetV2 { Url = ""; Authentication = None } } + PackageResolver.ResolvedPackage.Source = PackageSources.PackageSource.NuGetV2 { Url = ""; Authentication = None } + PackageResolver.IsRuntimeDependency = false } { Name = PackageName("other") Version = SemVer.Parse "1.0.0" Dependencies = Set.empty Unlisted = false Settings = Requirements.InstallSettings.Default - Source = PackageSources.PackageSource.NuGetV2 { Url = ""; Authentication = None } } + Source = PackageSources.PackageSource.NuGetV2 { Url = ""; Authentication = None } + IsRuntimeDependency = false } ] [] From 8f0435ad9a0e26d91679ad753efb798cb07c8e62 Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Tue, 18 Apr 2017 14:24:53 +0200 Subject: [PATCH 12/30] fix unit tests --- .../Properties/AssemblyInfo.cs | 12 ++-- src/Paket.Core/AssemblyInfo.fs | 12 ++-- src/Paket.Core/Files/DependenciesFile.fs | 14 +---- src/Paket.Core/FindOutdated.fs | 2 +- src/Paket.Core/Paket.Core.fsproj | 2 +- src/Paket.Core/RuntimeGraph.fs | 15 +++++ src/Paket.Core/UpdateProcess.fs | 5 +- src/Paket.PowerShell/AssemblyInfo.fs | 12 ++-- src/Paket/AssemblyInfo.fs | 12 ++-- .../DependencyGroupsAndRestrictions.fs | 2 +- .../Resolver/GlobalOptimisticStrategySpecs.fs | 2 +- .../GlobalPessimisticStrategySpecs.fs | 2 +- tests/Paket.Tests/Resolver/StrategySpecs.fs | 2 +- tests/Paket.Tests/TestHelpers.fs | 2 +- tests/Paket.Tests/UpdateProcessSpecs.fs | 63 ++++++++++--------- 15 files changed, 85 insertions(+), 74 deletions(-) diff --git a/src/Paket.Bootstrapper/Properties/AssemblyInfo.cs b/src/Paket.Bootstrapper/Properties/AssemblyInfo.cs index bf8da449ed..1b6b1877ba 100644 --- a/src/Paket.Bootstrapper/Properties/AssemblyInfo.cs +++ b/src/Paket.Bootstrapper/Properties/AssemblyInfo.cs @@ -4,16 +4,16 @@ [assembly: AssemblyTitleAttribute("Paket.Bootstrapper")] [assembly: AssemblyProductAttribute("Paket")] [assembly: AssemblyDescriptionAttribute("A dependency manager for .NET with support for NuGet packages and git repositories.")] -[assembly: AssemblyVersionAttribute("4.4.0")] -[assembly: AssemblyFileVersionAttribute("4.4.0")] -[assembly: AssemblyInformationalVersionAttribute("4.4.0")] +[assembly: AssemblyVersionAttribute("4.4.1")] +[assembly: AssemblyFileVersionAttribute("4.4.1")] +[assembly: AssemblyInformationalVersionAttribute("4.4.1")] namespace System { internal static class AssemblyVersionInformation { internal const System.String AssemblyTitle = "Paket.Bootstrapper"; internal const System.String AssemblyProduct = "Paket"; internal const System.String AssemblyDescription = "A dependency manager for .NET with support for NuGet packages and git repositories."; - internal const System.String AssemblyVersion = "4.4.0"; - internal const System.String AssemblyFileVersion = "4.4.0"; - internal const System.String AssemblyInformationalVersion = "4.4.0"; + internal const System.String AssemblyVersion = "4.4.1"; + internal const System.String AssemblyFileVersion = "4.4.1"; + internal const System.String AssemblyInformationalVersion = "4.4.1"; } } diff --git a/src/Paket.Core/AssemblyInfo.fs b/src/Paket.Core/AssemblyInfo.fs index 4c7d6f0dca..46ed993d9d 100644 --- a/src/Paket.Core/AssemblyInfo.fs +++ b/src/Paket.Core/AssemblyInfo.fs @@ -6,9 +6,9 @@ open System.Reflection [] [] [] -[] -[] -[] +[] +[] +[] do () module internal AssemblyVersionInformation = @@ -16,6 +16,6 @@ module internal AssemblyVersionInformation = let [] AssemblyProduct = "Paket" let [] AssemblyCompany = "Paket team" let [] AssemblyDescription = "A dependency manager for .NET with support for NuGet packages and git repositories." - let [] AssemblyVersion = "4.4.0" - let [] AssemblyFileVersion = "4.4.0" - let [] AssemblyInformationalVersion = "4.4.0" + let [] AssemblyVersion = "4.4.1" + let [] AssemblyFileVersion = "4.4.1" + let [] AssemblyInformationalVersion = "4.4.1" diff --git a/src/Paket.Core/Files/DependenciesFile.fs b/src/Paket.Core/Files/DependenciesFile.fs index e384a6bef9..ef17d43232 100644 --- a/src/Paket.Core/Files/DependenciesFile.fs +++ b/src/Paket.Core/Files/DependenciesFile.fs @@ -168,7 +168,7 @@ type DependenciesFile(fileName,groups:Map, textRepr member __.FileName = fileName member __.Lines = textRepresentation - member this.Resolve(force, getSha1, getVersionF, getPackageDetailsF, groupsToResolve:Map, updateMode) = + member this.Resolve(force, getSha1, getVersionF, getPackageDetailsF, getPackageRuntimeGraph, groupsToResolve:Map, updateMode) = let resolveGroup groupName _ = let group = this.GetGroup groupName @@ -221,15 +221,7 @@ type DependenciesFile(fileName,groups:Map, textRepr let runtimeGraph = resolved |> Map.toSeq |> Seq.map snd - // 1. downloading packages into cache - |> Seq.map (fun package -> package, NuGetV2.DownloadPackage (None, "C:\FakeRoot", package.Source, [], groupName, package.Name, package.Version, false, false, false) |> Async.RunSynchronously) - |> Seq.map (fun (p, (targetFileName, _)) -> p,targetFileName) - |> Seq.map (fun (package, t) -> package, NuGetV2.ExtractPackageToUserFolder (t, package.Name, package.Version, null) |> Async.RunSynchronously) - // 2. Get runtime graph - |> Seq.choose (fun (package, extracted) -> - let runtime = Path.Combine(extracted, "runtime.json") - if File.Exists runtime then Some (runtime) else None) - |> Seq.map RuntimeGraphParser.readRuntimeGraph + |> Seq.choose (getPackageRuntimeGraph groupName) |> RuntimeGraph.mergeSeq // 3. Resolve runtime deps and add it to the resolution let rids = RuntimeGraph.getKnownRids runtimeGraph @@ -264,7 +256,7 @@ type DependenciesFile(fileName,groups:Map, textRepr // Combine with existing resolution and mark runtime packages. // TODO: Warn if a package is part of both resolutions? // TODO: Warn if a runtime package contains a runtime.json? -> We don't download them here :/ - match resolution with + match runtimeResolution with | Resolution.Ok runtimeResolved -> let mapped = runtimeResolved diff --git a/src/Paket.Core/FindOutdated.fs b/src/Paket.Core/FindOutdated.fs index f00c39cf35..54186abfa2 100644 --- a/src/Paket.Core/FindOutdated.fs +++ b/src/Paket.Core/FindOutdated.fs @@ -51,7 +51,7 @@ let FindOutdated strict includingPrereleases groupNameFilter environment = trial | None -> dependenciesFile.Groups | Some gname -> dependenciesFile.Groups |> Map.filter(fun k g -> k.ToString() = gname) - let newResolution = dependenciesFile.Resolve(force, getSha1, getVersionsF, NuGetV2.GetPackageDetails alternativeProjectRoot root true, checkedDepsGroups, PackageResolver.UpdateMode.UpdateAll) + let newResolution = dependenciesFile.Resolve(force, getSha1, getVersionsF, NuGetV2.GetPackageDetails alternativeProjectRoot root true, RuntimeGraph.getRuntimeGraphFromNugetCache, checkedDepsGroups, PackageResolver.UpdateMode.UpdateAll) let checkedLockGroups = match groupNameFilter with diff --git a/src/Paket.Core/Paket.Core.fsproj b/src/Paket.Core/Paket.Core.fsproj index 6c60279ead..b6ba85886d 100644 --- a/src/Paket.Core/Paket.Core.fsproj +++ b/src/Paket.Core/Paket.Core.fsproj @@ -117,13 +117,13 @@ - + diff --git a/src/Paket.Core/RuntimeGraph.fs b/src/Paket.Core/RuntimeGraph.fs index b9c4b36a48..f7de1f2c8b 100644 --- a/src/Paket.Core/RuntimeGraph.fs +++ b/src/Paket.Core/RuntimeGraph.fs @@ -129,6 +129,8 @@ module Map = |> Map.ofSeq module RuntimeGraph = + open PackageResolver + let mergeCompatibility (s1:CompatibilityProfile) (s2:CompatibilityProfile) = assert (s1.Name = s2.Name) { Name = s1.Name @@ -183,3 +185,16 @@ module RuntimeGraph = |> Seq.tryHead |> Option.defaultValue [] + open System.IO + + let getRuntimeGraphFromNugetCache groupName (package:ResolvedPackage) = + // 1. downloading packages into cache + let targetFileName, _ = + NuGetV2.DownloadPackage (None, "C:\FakeRoot", package.Source, [], groupName, package.Name, package.Version, false, false, false) + |> Async.RunSynchronously + + let extractedDir = NuGetV2.ExtractPackageToUserFolder (targetFileName, package.Name, package.Version, null) |> Async.RunSynchronously + // 2. Get runtime graph + let runtime = Path.Combine(extractedDir, "runtime.json") + if File.Exists runtime then Some (runtime) else None + |> Option.map RuntimeGraphParser.readRuntimeGraph \ No newline at end of file diff --git a/src/Paket.Core/UpdateProcess.fs b/src/Paket.Core/UpdateProcess.fs index 9d9ed09171..07966a2ef3 100644 --- a/src/Paket.Core/UpdateProcess.fs +++ b/src/Paket.Core/UpdateProcess.fs @@ -10,7 +10,7 @@ open Chessie.ErrorHandling open Paket.Logging open InstallProcess -let selectiveUpdate force getSha1 getSortedVersionsF getPackageDetailsF (lockFile:LockFile) (dependenciesFile:DependenciesFile) updateMode semVerUpdateMode = +let selectiveUpdate force getSha1 getSortedVersionsF getPackageDetailsF getRuntimeGraphFromPackage (lockFile:LockFile) (dependenciesFile:DependenciesFile) updateMode semVerUpdateMode = let allVersions = Dictionary() let getSortedAndCachedVersionsF sources resolverStrategy groupName packageName : seq = let key = packageName,sources @@ -134,7 +134,7 @@ let selectiveUpdate force getSha1 getSortedVersionsF getPackageDetailsF (lockFil getVersionsF,getPackageDetailsF,groups - let resolution = dependenciesFile.Resolve(force, getSha1, getVersionsF, getPackageDetailsF, groupsToUpdate, updateMode) + let resolution = dependenciesFile.Resolve(force, getSha1, getVersionsF, getPackageDetailsF, getRuntimeGraphFromPackage, groupsToUpdate, updateMode) let groups = dependenciesFile.Groups @@ -203,6 +203,7 @@ let SelectiveUpdate(dependenciesFile : DependenciesFile, alternativeProjectRoot, getSha1 getVersionsF (NuGetV2.GetPackageDetails alternativeProjectRoot root force) + (RuntimeGraph.getRuntimeGraphFromNugetCache) oldLockFile dependenciesFile updateMode diff --git a/src/Paket.PowerShell/AssemblyInfo.fs b/src/Paket.PowerShell/AssemblyInfo.fs index 7c7fee557f..ef135986db 100644 --- a/src/Paket.PowerShell/AssemblyInfo.fs +++ b/src/Paket.PowerShell/AssemblyInfo.fs @@ -6,9 +6,9 @@ open System.Reflection [] [] [] -[] -[] -[] +[] +[] +[] do () module internal AssemblyVersionInformation = @@ -16,6 +16,6 @@ module internal AssemblyVersionInformation = let [] AssemblyProduct = "Paket" let [] AssemblyCompany = "Paket team" let [] AssemblyDescription = "A dependency manager for .NET with support for NuGet packages and git repositories." - let [] AssemblyVersion = "4.4.0" - let [] AssemblyFileVersion = "4.4.0" - let [] AssemblyInformationalVersion = "4.4.0" + let [] AssemblyVersion = "4.4.1" + let [] AssemblyFileVersion = "4.4.1" + let [] AssemblyInformationalVersion = "4.4.1" diff --git a/src/Paket/AssemblyInfo.fs b/src/Paket/AssemblyInfo.fs index 7a061c0194..9eeee192dc 100644 --- a/src/Paket/AssemblyInfo.fs +++ b/src/Paket/AssemblyInfo.fs @@ -6,9 +6,9 @@ open System.Reflection [] [] [] -[] -[] -[] +[] +[] +[] do () module internal AssemblyVersionInformation = @@ -16,6 +16,6 @@ module internal AssemblyVersionInformation = let [] AssemblyProduct = "Paket" let [] AssemblyCompany = "Paket team" let [] AssemblyDescription = "A dependency manager for .NET with support for NuGet packages and git repositories." - let [] AssemblyVersion = "4.4.0" - let [] AssemblyFileVersion = "4.4.0" - let [] AssemblyInformationalVersion = "4.4.0" + let [] AssemblyVersion = "4.4.1" + let [] AssemblyFileVersion = "4.4.1" + let [] AssemblyInformationalVersion = "4.4.1" diff --git a/tests/Paket.Tests/Resolver/DependencyGroupsAndRestrictions.fs b/tests/Paket.Tests/Resolver/DependencyGroupsAndRestrictions.fs index 6446e4dbea..d2167fbdc3 100644 --- a/tests/Paket.Tests/Resolver/DependencyGroupsAndRestrictions.fs +++ b/tests/Paket.Tests/Resolver/DependencyGroupsAndRestrictions.fs @@ -9,7 +9,7 @@ open Paket.PackageResolver let resolve graph updateMode (cfg : DependenciesFile) = let groups = [Constants.MainDependencyGroup, None ] |> Map.ofSeq - cfg.Resolve(true,noSha1,VersionsFromGraphAsSeq graph,PackageDetailsFromGraph graph,groups,updateMode).[Constants.MainDependencyGroup].ResolvedPackages.GetModelOrFail() + cfg.Resolve(true,noSha1,VersionsFromGraphAsSeq graph,PackageDetailsFromGraph graph,(fun _ _ -> None),groups,updateMode).[Constants.MainDependencyGroup].ResolvedPackages.GetModelOrFail() let graph1 = GraphOfNuspecs [ diff --git a/tests/Paket.Tests/Resolver/GlobalOptimisticStrategySpecs.fs b/tests/Paket.Tests/Resolver/GlobalOptimisticStrategySpecs.fs index 6fad93f6ca..827765e099 100644 --- a/tests/Paket.Tests/Resolver/GlobalOptimisticStrategySpecs.fs +++ b/tests/Paket.Tests/Resolver/GlobalOptimisticStrategySpecs.fs @@ -9,7 +9,7 @@ open Paket.PackageResolver let resolve graph updateMode (cfg : DependenciesFile) = let groups = [Constants.MainDependencyGroup, None ] |> Map.ofSeq - cfg.Resolve(true,noSha1,VersionsFromGraphAsSeq graph,PackageDetailsFromGraph graph,groups,updateMode).[Constants.MainDependencyGroup].ResolvedPackages.GetModelOrFail() + cfg.Resolve(true,noSha1,VersionsFromGraphAsSeq graph,PackageDetailsFromGraph graph,(fun _ _ -> None),groups,updateMode).[Constants.MainDependencyGroup].ResolvedPackages.GetModelOrFail() let graph = OfSimpleGraph [ diff --git a/tests/Paket.Tests/Resolver/GlobalPessimisticStrategySpecs.fs b/tests/Paket.Tests/Resolver/GlobalPessimisticStrategySpecs.fs index b3763f8e68..810eaa484e 100644 --- a/tests/Paket.Tests/Resolver/GlobalPessimisticStrategySpecs.fs +++ b/tests/Paket.Tests/Resolver/GlobalPessimisticStrategySpecs.fs @@ -9,7 +9,7 @@ open Paket.PackageResolver let resolve graph updateMode (cfg : DependenciesFile) = let groups = [Constants.MainDependencyGroup, None ] |> Map.ofSeq - cfg.Resolve(true,noSha1,VersionsFromGraphAsSeq graph,PackageDetailsFromGraph graph,groups,updateMode).[Constants.MainDependencyGroup].ResolvedPackages.GetModelOrFail() + cfg.Resolve(true,noSha1,VersionsFromGraphAsSeq graph,PackageDetailsFromGraph graph,(fun _ _ -> None),groups,updateMode).[Constants.MainDependencyGroup].ResolvedPackages.GetModelOrFail() let graph = OfSimpleGraph [ diff --git a/tests/Paket.Tests/Resolver/StrategySpecs.fs b/tests/Paket.Tests/Resolver/StrategySpecs.fs index 34e9736343..4764ab80d0 100644 --- a/tests/Paket.Tests/Resolver/StrategySpecs.fs +++ b/tests/Paket.Tests/Resolver/StrategySpecs.fs @@ -9,7 +9,7 @@ open Paket.PackageResolver let resolve graph updateMode (cfg : DependenciesFile) = let groups = [Constants.MainDependencyGroup, None ] |> Map.ofSeq - cfg.Resolve(true,noSha1,VersionsFromGraphAsSeq graph,PackageDetailsFromGraph graph,groups,updateMode).[Constants.MainDependencyGroup].ResolvedPackages.GetModelOrFail() + cfg.Resolve(true,noSha1,VersionsFromGraphAsSeq graph,PackageDetailsFromGraph graph,(fun _ _ -> None),groups,updateMode).[Constants.MainDependencyGroup].ResolvedPackages.GetModelOrFail() let graph = OfSimpleGraph [ diff --git a/tests/Paket.Tests/TestHelpers.fs b/tests/Paket.Tests/TestHelpers.fs index d8de5cd65d..67069834bb 100644 --- a/tests/Paket.Tests/TestHelpers.fs +++ b/tests/Paket.Tests/TestHelpers.fs @@ -83,7 +83,7 @@ let resolve graph dependencies = (safeResolve graph dependencies).GetModelOrFail let ResolveWithGraph(dependenciesFile:DependenciesFile,getSha1,getVersionsF, getPackageDetailsF) = let groups = [Constants.MainDependencyGroup, None ] |> Map.ofSeq - dependenciesFile.Resolve(true,getSha1,getVersionsF,getPackageDetailsF,groups,UpdateMode.UpdateAll) + dependenciesFile.Resolve(true,getSha1,getVersionsF,getPackageDetailsF,(fun _ _ -> None),groups,UpdateMode.UpdateAll) let getVersion (resolved:ResolvedPackage) = resolved.Version.ToString() diff --git a/tests/Paket.Tests/UpdateProcessSpecs.fs b/tests/Paket.Tests/UpdateProcessSpecs.fs index 898013055e..f6883c54a2 100644 --- a/tests/Paket.Tests/UpdateProcessSpecs.fs +++ b/tests/Paket.Tests/UpdateProcessSpecs.fs @@ -45,6 +45,9 @@ let graph = let getLockFile lockFileData = LockFile.Parse("",toLines lockFileData) let lockFile = lockFileData |> getLockFile +let selectiveUpdateFromGraph graph force lockFile depsFile updateMode restriction = + selectiveUpdate force noSha1 (VersionsFromGraph graph) (PackageDetailsFromGraph graph) (fun _ _ -> None) lockFile depsFile updateMode restriction + [] let ``SelectiveUpdate does not update any package when it is neither updating all nor selective updating``() = @@ -53,7 +56,7 @@ let ``SelectiveUpdate does not update any package when it is neither updating al nuget Castle.Core-log4net ~> 3.2 nuget FAKE""") - let lockFile,_ = selectiveUpdate true noSha1 (VersionsFromGraph graph) (PackageDetailsFromGraph graph) lockFile dependenciesFile PackageResolver.UpdateMode.Install SemVerUpdateMode.NoRestriction + let lockFile,_ = selectiveUpdateFromGraph graph true lockFile dependenciesFile PackageResolver.UpdateMode.Install SemVerUpdateMode.NoRestriction let result = lockFile.GetGroupedResolution() @@ -78,7 +81,7 @@ let ``SelectiveUpdate updates all packages not constraining version``() = nuget Castle.Core-log4net ~> 3.2 nuget FAKE""") - let lockFile,_ = selectiveUpdate true noSha1 (VersionsFromGraph graph) (PackageDetailsFromGraph graph) lockFile dependenciesFile PackageResolver.UpdateMode.UpdateAll SemVerUpdateMode.NoRestriction + let lockFile,_ = selectiveUpdateFromGraph graph true lockFile dependenciesFile PackageResolver.UpdateMode.UpdateAll SemVerUpdateMode.NoRestriction let result = lockFile.GetGroupedResolution() @@ -104,7 +107,7 @@ let ``SelectiveUpdate updates all packages constraining version``() = nuget Castle.Core ~> 3.2 nuget FAKE = 4.0.0""") - let lockFile,_ = selectiveUpdate true noSha1 (VersionsFromGraph graph) (PackageDetailsFromGraph graph) lockFile dependenciesFile PackageResolver.UpdateMode.UpdateAll SemVerUpdateMode.NoRestriction + let lockFile,_ = selectiveUpdateFromGraph graph true lockFile dependenciesFile PackageResolver.UpdateMode.UpdateAll SemVerUpdateMode.NoRestriction let result = lockFile.GetGroupedResolution() @@ -129,7 +132,7 @@ let ``SelectiveUpdate removes a dependency when it is updated to a version that nuget Castle.Core-log4net nuget FAKE""") - let lockFile,_ = selectiveUpdate true noSha1 (VersionsFromGraph graph) (PackageDetailsFromGraph graph) lockFile dependenciesFile PackageResolver.UpdateMode.UpdateAll SemVerUpdateMode.NoRestriction + let lockFile,_ = selectiveUpdateFromGraph graph true lockFile dependenciesFile PackageResolver.UpdateMode.UpdateAll SemVerUpdateMode.NoRestriction let result = lockFile.GetGroupedResolution() @@ -155,7 +158,7 @@ let ``SelectiveUpdate updates a single package``() = nuget FAKE""") let lockFile,_ = - selectiveUpdate true noSha1 (VersionsFromGraph graph) (PackageDetailsFromGraph graph) lockFile dependenciesFile + selectiveUpdateFromGraph graph true lockFile dependenciesFile (PackageResolver.UpdateMode.UpdateFiltered(Constants.MainDependencyGroup, PackageName "FAKE" |> PackageFilter.ofName)) SemVerUpdateMode.NoRestriction let result = @@ -182,7 +185,7 @@ let ``SelectiveUpdate updates a single constrained package``() = nuget FAKE""") let lockFile,_ = - selectiveUpdate true noSha1 (VersionsFromGraph graph) (PackageDetailsFromGraph graph) lockFile dependenciesFile + selectiveUpdateFromGraph graph true lockFile dependenciesFile (PackageResolver.UpdateMode.UpdateFiltered(Constants.MainDependencyGroup, PackageName "Castle.Core-log4net" |> PackageFilter.ofName)) SemVerUpdateMode.NoRestriction let result = @@ -210,7 +213,7 @@ let ``SelectiveUpdate updates a single package with constrained dependency in de nuget FAKE""") let lockFile,_ = - selectiveUpdate true noSha1 (VersionsFromGraph graph) (PackageDetailsFromGraph graph) lockFile dependenciesFile + selectiveUpdateFromGraph graph true lockFile dependenciesFile (PackageResolver.UpdateMode.UpdateFiltered(Constants.MainDependencyGroup, PackageName "Castle.Core-log4net" |> PackageFilter.ofName)) SemVerUpdateMode.NoRestriction let result = @@ -237,7 +240,7 @@ let ``SelectiveUpdate installs new packages``() = nuget FAKE nuget Newtonsoft.Json""") - let lockFile,_ = selectiveUpdate true noSha1 (VersionsFromGraph graph) (PackageDetailsFromGraph graph) lockFile dependenciesFile PackageResolver.UpdateMode.Install SemVerUpdateMode.NoRestriction + let lockFile,_ = selectiveUpdateFromGraph graph true lockFile dependenciesFile PackageResolver.UpdateMode.Install SemVerUpdateMode.NoRestriction let result = lockFile.GetGroupedResolution() @@ -264,7 +267,7 @@ let ``SelectiveUpdate removes a dependency when it updates a single package and nuget FAKE""") let lockFile,_ = - selectiveUpdate true noSha1 (VersionsFromGraph graph) (PackageDetailsFromGraph graph) lockFile dependenciesFile + selectiveUpdateFromGraph graph true lockFile dependenciesFile (PackageResolver.UpdateMode.UpdateFiltered(Constants.MainDependencyGroup, PackageName "Castle.Core-log4net" |> PackageFilter.ofName)) SemVerUpdateMode.NoRestriction let result = @@ -292,7 +295,7 @@ let ``SelectiveUpdate does not update when a dependency constrain is not met``() nuget FAKE""") let lockFile,_ = - selectiveUpdate true noSha1 (VersionsFromGraph graph) (PackageDetailsFromGraph graph) lockFile dependenciesFile + selectiveUpdateFromGraph graph true lockFile dependenciesFile (PackageResolver.UpdateMode.UpdateFiltered(Constants.MainDependencyGroup, PackageName "Castle.Core-log4net" |> PackageFilter.ofName)) SemVerUpdateMode.NoRestriction let result = lockFile.GetGroupedResolution() @@ -319,7 +322,7 @@ let ``SelectiveUpdate considers package name case difference``() = nuget FAKE""") let lockFile,_ = - selectiveUpdate true noSha1 (VersionsFromGraph graph) (PackageDetailsFromGraph graph) lockFile dependenciesFile + selectiveUpdateFromGraph graph true lockFile dependenciesFile (PackageResolver.UpdateMode.UpdateFiltered(Constants.MainDependencyGroup, PackageName "Castle.Core-log4net" |> PackageFilter.ofName)) SemVerUpdateMode.NoRestriction let result = @@ -348,7 +351,7 @@ let ``SelectiveUpdate conflicts when a dependency is contrained``() = nuget FAKE""") (fun () -> - selectiveUpdate true noSha1 (VersionsFromGraph graph) (PackageDetailsFromGraph graph) lockFile dependenciesFile + selectiveUpdateFromGraph graph true lockFile dependenciesFile (PackageResolver.UpdateMode.UpdateFiltered(Constants.MainDependencyGroup, PackageName "Castle.Core-log4net" |> PackageFilter.ofName)) SemVerUpdateMode.NoRestriction |> ignore) |> shouldFail @@ -363,7 +366,7 @@ let ``SelectiveUpdate generates paket.lock correctly``() = nuget FAKE""") let lockFile,_ = - selectiveUpdate true noSha1 (VersionsFromGraph graph) (PackageDetailsFromGraph graph) lockFile dependenciesFile + selectiveUpdateFromGraph graph true lockFile dependenciesFile (PackageResolver.UpdateMode.UpdateFiltered(Constants.MainDependencyGroup, PackageName "Castle.Core" |> PackageFilter.ofName)) SemVerUpdateMode.NoRestriction let result = @@ -438,7 +441,7 @@ let ``SelectiveUpdate updates package that conflicts with a transitive dependenc let packageFilter = PackageName "log4f" |> PackageFilter.ofName let lockFile,_ = - selectiveUpdate true noSha1 (VersionsFromGraph graph2) (PackageDetailsFromGraph graph2) lockFile2 dependenciesFile + selectiveUpdateFromGraph graph2 true lockFile2 dependenciesFile (PackageResolver.UpdateMode.UpdateFiltered(Constants.MainDependencyGroup, packageFilter)) SemVerUpdateMode.NoRestriction let result = @@ -469,7 +472,7 @@ let ``SelectiveUpdate updates package that conflicts with a transitive dependenc let packageFilter = PackageName "Ninject.Extensions.Logging.Log4net" |> PackageFilter.ofName let lockFile,_ = - selectiveUpdate true noSha1 (VersionsFromGraph graph2) (PackageDetailsFromGraph graph2) lockFile2 dependenciesFile + selectiveUpdateFromGraph graph2 true lockFile2 dependenciesFile (PackageResolver.UpdateMode.UpdateFiltered(Constants.MainDependencyGroup, packageFilter)) SemVerUpdateMode.NoRestriction let result = @@ -527,7 +530,7 @@ let ``SelectiveUpdate updates package that conflicts with a transitive dependenc let packageFilter = PackageName "Ninject.Extensions.Logging.Log4net" |> PackageFilter.ofName let lockFile,_ = - selectiveUpdate true noSha1 (VersionsFromGraph graph3) (PackageDetailsFromGraph graph3) lockFile3 dependenciesFile + selectiveUpdateFromGraph graph3 true lockFile3 dependenciesFile (PackageResolver.UpdateMode.UpdateFiltered(Constants.MainDependencyGroup, packageFilter)) SemVerUpdateMode.NoRestriction let result = @@ -560,7 +563,7 @@ let ``SelectiveUpdate does not conflict with a transitive dependency of another let packageFilter = PackageName "Ninject" |> PackageFilter.ofName let lockFile,_ = - selectiveUpdate true noSha1 (VersionsFromGraph graph3) (PackageDetailsFromGraph graph3) lockFile3 dependenciesFile + selectiveUpdateFromGraph graph3 true lockFile3 dependenciesFile (PackageResolver.UpdateMode.UpdateFiltered(Constants.MainDependencyGroup, packageFilter)) SemVerUpdateMode.NoRestriction let result = @@ -592,7 +595,7 @@ let ``SelectiveUpdate updates package that conflicts with a deep transitive depe let packageFilter = PackageName "Ninject.Extensions.Interception" |> PackageFilter.ofName let lockFile,_ = - selectiveUpdate true noSha1 (VersionsFromGraph graph3) (PackageDetailsFromGraph graph3) lockFile3 dependenciesFile + selectiveUpdateFromGraph graph3 true lockFile3 dependenciesFile (PackageResolver.UpdateMode.UpdateFiltered(Constants.MainDependencyGroup, packageFilter)) SemVerUpdateMode.NoRestriction let result = @@ -645,7 +648,7 @@ let ``SelectiveUpdate updates package that conflicts with a deep transitive depe let packageFilter = PackageName "Ninject.Extensions.Logging.Log4net.Deep" |> PackageFilter.ofName let lockFile,_ = - selectiveUpdate true noSha1 (VersionsFromGraph graph4) (PackageDetailsFromGraph graph4) lockFile4 dependenciesFile + selectiveUpdateFromGraph graph4 true lockFile4 dependenciesFile (PackageResolver.UpdateMode.UpdateFiltered(Constants.MainDependencyGroup, packageFilter)) SemVerUpdateMode.NoRestriction let result = @@ -696,7 +699,7 @@ let ``SelectiveUpdate updates package that conflicts with transitive dependency let packageFilter = PackageName "Ninject.Extensions.Logging" |> PackageFilter.ofName let lockFile,_ = - selectiveUpdate true noSha1 (VersionsFromGraph graph5) (PackageDetailsFromGraph graph5) lockFile5 dependenciesFile + selectiveUpdateFromGraph graph5 true lockFile5 dependenciesFile (PackageResolver.UpdateMode.UpdateFiltered(Constants.MainDependencyGroup, packageFilter)) SemVerUpdateMode.NoRestriction let result = @@ -734,7 +737,7 @@ let ``SelectiveUpdate updates all packages from all groups if no group is specif nuget Castle.Core-log4net ~> 4.0""") - let lockFile,_ = selectiveUpdate true noSha1 (VersionsFromGraph graph) (PackageDetailsFromGraph graph) lockFile dependenciesFile PackageResolver.UpdateMode.UpdateAll SemVerUpdateMode.NoRestriction + let lockFile,_ = selectiveUpdateFromGraph graph true lockFile dependenciesFile PackageResolver.UpdateMode.UpdateAll SemVerUpdateMode.NoRestriction let result = groupMap lockFile @@ -785,7 +788,7 @@ let ``SelectiveUpdate updates only packages from specific group if group is spec nuget Castle.Core-log4net""") - let lockFile,_ = selectiveUpdate true noSha1 (VersionsFromGraph graph) (PackageDetailsFromGraph graph) groupedLockFile dependenciesFile (PackageResolver.UpdateMode.UpdateGroup Constants.MainDependencyGroup) SemVerUpdateMode.NoRestriction + let lockFile,_ = selectiveUpdateFromGraph graph true groupedLockFile dependenciesFile (PackageResolver.UpdateMode.UpdateGroup Constants.MainDependencyGroup) SemVerUpdateMode.NoRestriction let result = groupMap lockFile |> Seq.toList @@ -817,7 +820,7 @@ let ``SelectiveUpdate updates only packages from specified group``() = nuget Castle.Core-log4net""") - let lockFile,_ = selectiveUpdate true noSha1 (VersionsFromGraph graph) (PackageDetailsFromGraph graph) groupedLockFile dependenciesFile (PackageResolver.UpdateMode.UpdateGroup(GroupName "Group")) SemVerUpdateMode.NoRestriction + let lockFile,_ = selectiveUpdateFromGraph graph true groupedLockFile dependenciesFile (PackageResolver.UpdateMode.UpdateGroup(GroupName "Group")) SemVerUpdateMode.NoRestriction let result = groupMap lockFile @@ -873,7 +876,7 @@ let ``SelectiveUpdate updates package from a specific group``() = nuget FAKE""") let lockFile,_ = - selectiveUpdate true noSha1 (VersionsFromGraph graph) (PackageDetailsFromGraph graph) lockFile6 dependenciesFile + selectiveUpdateFromGraph graph true lockFile6 dependenciesFile (PackageResolver.UpdateMode.UpdateFiltered(GroupName "Group", PackageName "Castle.Core-log4net" |> PackageFilter.ofName)) SemVerUpdateMode.NoRestriction let result = groupMap lockFile @@ -909,7 +912,7 @@ let ``SelectiveUpdate does not remove a dependency from group when it is a top-l nuget log4net""") let lockFile,_ = - selectiveUpdate true noSha1 (VersionsFromGraph graph) (PackageDetailsFromGraph graph) lockFile6 dependenciesFile + selectiveUpdateFromGraph graph true lockFile6 dependenciesFile (PackageResolver.UpdateMode.UpdateFiltered(GroupName "Group", PackageName "Castle.Core-log4net" |> PackageFilter.ofName)) SemVerUpdateMode.NoRestriction let result = groupMap lockFile @@ -944,7 +947,7 @@ let ``SelectiveUpdate updates package from main group``() = nuget FAKE""") let lockFile,_ = - selectiveUpdate true noSha1 (VersionsFromGraph graph) (PackageDetailsFromGraph graph) lockFile6 dependenciesFile + selectiveUpdateFromGraph graph true lockFile6 dependenciesFile (PackageResolver.UpdateMode.UpdateFiltered(Constants.MainDependencyGroup, PackageName "Castle.Core-log4net" |> PackageFilter.ofName)) SemVerUpdateMode.NoRestriction let result = groupMap lockFile @@ -990,7 +993,7 @@ let ``SelectiveUpdate updates package that has a new dependent package that also nuget Package""") let lockFile,_ = - selectiveUpdate true noSha1 (VersionsFromGraph graph7) (PackageDetailsFromGraph graph7) lockFile7 dependenciesFile + selectiveUpdateFromGraph graph7 true lockFile7 dependenciesFile (PackageResolver.UpdateMode.UpdateFiltered(Constants.MainDependencyGroup, PackageName "Package" |> PackageFilter.ofName)) SemVerUpdateMode.NoRestriction let result = @@ -1024,7 +1027,7 @@ let ``SelectiveUpdate updates early package that has a new dependent package tha nuget APackage""") let lockFile,_ = - selectiveUpdate true noSha1 (VersionsFromGraph graph7) (PackageDetailsFromGraph graph7) lockFile8 dependenciesFile + selectiveUpdateFromGraph graph7 true lockFile8 dependenciesFile (PackageResolver.UpdateMode.UpdateFiltered(Constants.MainDependencyGroup, PackageName "APackage" |> PackageFilter.ofName)) SemVerUpdateMode.NoRestriction let result = @@ -1056,7 +1059,7 @@ let ``SelectiveUpdate with SemVerUpdateMode.Minor updates package from a specifi nuget FAKE""") let lockFile,_ = - selectiveUpdate true noSha1 (VersionsFromGraph graph) (PackageDetailsFromGraph graph) lockFile6 dependenciesFile + selectiveUpdateFromGraph graph true lockFile6 dependenciesFile (PackageResolver.UpdateMode.UpdateFiltered(GroupName "Group", PackageName "Castle.Core-log4net" |> PackageFilter.ofName)) SemVerUpdateMode.KeepMinor let result = groupMap lockFile @@ -1078,7 +1081,7 @@ let ``SelectiveUpdate with SemVerUpdateMode.Minor updates package from a specifi [] let ``adding new group to lockfile should not crash``() = - let update deps lock = selectiveUpdate true noSha1 (VersionsFromGraph graph) (PackageDetailsFromGraph graph) lock deps UpdateMode.Install SemVerUpdateMode.NoRestriction + let update deps lock = selectiveUpdateFromGraph graph true lock deps UpdateMode.Install SemVerUpdateMode.NoRestriction let initialDepsText = """source http://www.nuget.org/api/v2 From 244cb1afd07d56dccfd67fa168335f86865e25b9 Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Tue, 18 Apr 2017 15:28:38 +0200 Subject: [PATCH 13/30] fix more real-life tests --- src/Paket.Core/Files/DependenciesFile.fs | 6 +++++- src/Paket.Core/RuntimeGraph.fs | 1 + src/Paket/Paket.fsproj | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Paket.Core/Files/DependenciesFile.fs b/src/Paket.Core/Files/DependenciesFile.fs index ef17d43232..72ce26a1aa 100644 --- a/src/Paket.Core/Files/DependenciesFile.fs +++ b/src/Paket.Core/Files/DependenciesFile.fs @@ -261,7 +261,11 @@ type DependenciesFile(fileName,groups:Map, textRepr let mapped = runtimeResolved |> Map.map (fun _ v -> { v with IsRuntimeDependency = true }) - Map.merge (fun p1 p2 -> failwithf "same package '%A' in runtime and regular resolution" p1) resolved mapped + Map.merge (fun p1 p2 -> + if p1.Version = p2.Version then + p1 + else + failwithf "same package '%A' in runtime '%A' and regular '%A' resolution with different versions" p1.Name p1.Version p2.Version) resolved mapped |> Resolution.Ok | _ -> resolution | Resolution.Conflict _ -> resolution diff --git a/src/Paket.Core/RuntimeGraph.fs b/src/Paket.Core/RuntimeGraph.fs index f7de1f2c8b..d4a7308872 100644 --- a/src/Paket.Core/RuntimeGraph.fs +++ b/src/Paket.Core/RuntimeGraph.fs @@ -197,4 +197,5 @@ module RuntimeGraph = // 2. Get runtime graph let runtime = Path.Combine(extractedDir, "runtime.json") if File.Exists runtime then Some (runtime) else None + |> Option.map File.ReadAllText |> Option.map RuntimeGraphParser.readRuntimeGraph \ No newline at end of file diff --git a/src/Paket/Paket.fsproj b/src/Paket/Paket.fsproj index 572df4068b..ab807f987c 100644 --- a/src/Paket/Paket.fsproj +++ b/src/Paket/Paket.fsproj @@ -37,8 +37,8 @@ D:\temp\coreclrtest install C:\dev\src\Paket\integrationtests\scenarios\loading-scripts\dependencies-file-flag\temp - install - C:\PROJ\Paket\integrationtests\scenarios\i001467-cpp-native\temp + update + C:\PROJ\Paket\integrationtests\scenarios\i000051-resolve-pessimistic\temp pdbonly From b5a96a2d335f1920996c272a4f76f9c3e5507686 Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Tue, 18 Apr 2017 15:48:39 +0200 Subject: [PATCH 14/30] add comment --- src/Paket.Core/Files/DependenciesFile.fs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Paket.Core/Files/DependenciesFile.fs b/src/Paket.Core/Files/DependenciesFile.fs index 72ce26a1aa..3449515c9a 100644 --- a/src/Paket.Core/Files/DependenciesFile.fs +++ b/src/Paket.Core/Files/DependenciesFile.fs @@ -242,6 +242,9 @@ type DependenciesFile(fileName,groups:Map, textRepr Settings = group.Options.Settings }) |> Seq.toList + // TODO: We might want a way here to tell the resolver: + // "We don't really want Package A, but if you need it take Version X (from our resolution above)" + // Maybe we can actually do this by modifying the "getVersionF" callback? let runtimeResolution = PackageResolver.Resolve( getVersionF, From c71d62b088ac10eb07e9a1e2d22708582572c6b2 Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Tue, 18 Apr 2017 16:06:05 +0200 Subject: [PATCH 15/30] add comments to RuntimeGraph --- src/Paket.Core/RuntimeGraph.fs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/Paket.Core/RuntimeGraph.fs b/src/Paket.Core/RuntimeGraph.fs index d4a7308872..a1d4e2a774 100644 --- a/src/Paket.Core/RuntimeGraph.fs +++ b/src/Paket.Core/RuntimeGraph.fs @@ -7,6 +7,7 @@ open Domain // Example files can be found in the packages "Microsoft.NETCore.Platforms 1.1.0" and "Microsoft.NETCore.Targets 1.1.0" +/// The runtime identifiert for a specific runtime. Should be treated as a black box in combination with the operations defined on the RuntimeGraph type Rid = private { Rid : string } static member Of s = { Rid = s } @@ -15,15 +16,18 @@ type Rid = type CompatibilityProfileName = string +/// A compatibility profile identifies which RIDs are compatible with what FrameworkIdentifier (TargetFrameworkMoniker/tfm in NuGet world) type CompatibilityProfile = { Name : CompatibilityProfileName Supported : Map } +/// The description for a particular RID, indicates inherited (compatible) RIDs and runtime dependencies for this RID. type RuntimeDescription = { Rid : Rid InheritedRids : Rid list RuntimeDependencies : Map } +/// The runtime graph consolidating compatibility informations across the different RIDs type RuntimeGraph = { Supports : Map Runtimes : Map } @@ -32,6 +36,7 @@ type RuntimeGraph = open Newtonsoft.Json open Newtonsoft.Json.Linq +/// A module for parsing runtime.json files contained in various packages. module RuntimeGraphParser = open System.Collections.Generic @@ -128,6 +133,7 @@ module Map = | _ -> failwithf "This should never happen") |> Map.ofSeq +// Defines common operations on the runtime graph module RuntimeGraph = open PackageResolver @@ -144,13 +150,14 @@ module RuntimeGraph = RuntimeDependencies = Map.merge (@) d1.RuntimeDependencies d2.RuntimeDependencies |> Map.map (fun _ l -> List.distinct l) } + /// merge two runtime graphs let merge (r1:RuntimeGraph) (r2:RuntimeGraph) = { Supports = Map.merge mergeCompatibility r1.Supports r2.Supports Runtimes = Map.merge mergeDescription r1.Runtimes r2.Runtimes } - + /// merge a sequence of runtime graphs let mergeSeq s = s |> Seq.fold merge RuntimeGraph.Empty - + /// get the list of compatible RIDs for the given RID. Most compatible are near the head. The list contains the given RID in the HEAD let getInheritanceList (rid:Rid) (g:RuntimeGraph) = let rec getListRec currentList toInspect = match toInspect with @@ -166,15 +173,16 @@ module RuntimeGraph = | _ -> currentList getListRec [rid] [rid] - + /// get a list of RIDs in no particular order which are part of this runtime graph let getKnownRids (g:RuntimeGraph) = g.Runtimes |> Map.toSeq |> Seq.map fst - + /// calculates whether the given assetRid is compatible with the given projectRid. + /// consider a project targeting projectRid, this returns true if an asset with assetRid is comaptible. let areCompatible projectRid assetRid g = g |> getInheritanceList projectRid |> List.contains assetRid - + /// return runtime depenendencies for the given package and runtime let findRuntimeDependencies rid packageName g = getInheritanceList rid g |> Seq.choose (fun r -> @@ -186,7 +194,7 @@ module RuntimeGraph = |> Option.defaultValue [] open System.IO - + /// Downloads the given package into the nuget cache and read its runtime.json. let getRuntimeGraphFromNugetCache groupName (package:ResolvedPackage) = // 1. downloading packages into cache let targetFileName, _ = From 1af9f3334f387acd0c509d9f79b8e5bd86e49a88 Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Tue, 18 Apr 2017 17:03:39 +0200 Subject: [PATCH 16/30] make local nuget feeds work as well. --- src/Paket.Core/Files/DependenciesFile.fs | 3 ++- src/Paket.Core/FindOutdated.fs | 2 +- src/Paket.Core/NuGetV2.fs | 17 +++++++++++++++++ src/Paket.Core/RestoreProcess.fs | 1 + src/Paket.Core/RuntimeGraph.fs | 4 ++-- src/Paket.Core/UpdateProcess.fs | 2 +- src/Paket/Paket.fsproj | 2 +- 7 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/Paket.Core/Files/DependenciesFile.fs b/src/Paket.Core/Files/DependenciesFile.fs index 4bcc8c4de5..84c823b615 100644 --- a/src/Paket.Core/Files/DependenciesFile.fs +++ b/src/Paket.Core/Files/DependenciesFile.fs @@ -223,11 +223,12 @@ type DependenciesFile(fileName,groups:Map, textRepr match resolution with | Resolution.Ok resolved -> // runtime resolution step - let runtimeGraph = + let runtimeGraph = // setting this variable to empty is the fastest way to disable runtime deps resolution resolved |> Map.toSeq |> Seq.map snd |> Seq.choose (getPackageRuntimeGraph groupName) |> RuntimeGraph.mergeSeq + //RuntimeGraph.Empty // 3. Resolve runtime deps and add it to the resolution let rids = RuntimeGraph.getKnownRids runtimeGraph let runtimeDeps = diff --git a/src/Paket.Core/FindOutdated.fs b/src/Paket.Core/FindOutdated.fs index 54186abfa2..83e93a9641 100644 --- a/src/Paket.Core/FindOutdated.fs +++ b/src/Paket.Core/FindOutdated.fs @@ -51,7 +51,7 @@ let FindOutdated strict includingPrereleases groupNameFilter environment = trial | None -> dependenciesFile.Groups | Some gname -> dependenciesFile.Groups |> Map.filter(fun k g -> k.ToString() = gname) - let newResolution = dependenciesFile.Resolve(force, getSha1, getVersionsF, NuGetV2.GetPackageDetails alternativeProjectRoot root true, RuntimeGraph.getRuntimeGraphFromNugetCache, checkedDepsGroups, PackageResolver.UpdateMode.UpdateAll) + let newResolution = dependenciesFile.Resolve(force, getSha1, getVersionsF, NuGetV2.GetPackageDetails alternativeProjectRoot root true, RuntimeGraph.getRuntimeGraphFromNugetCache root, checkedDepsGroups, PackageResolver.UpdateMode.UpdateAll) let checkedLockGroups = match groupNameFilter with diff --git a/src/Paket.Core/NuGetV2.fs b/src/Paket.Core/NuGetV2.fs index c14632b8c5..8b74ae9acc 100644 --- a/src/Paket.Core/NuGetV2.fs +++ b/src/Paket.Core/NuGetV2.fs @@ -940,6 +940,23 @@ let DownloadPackage(alternativeProjectRoot, root, (source : PackageSource), cach elif not force && getFromCache caches then () else + match source with + | LocalNuGet(path,_) -> + let path = Utils.normalizeLocalPath path + let di = Utils.getDirectoryInfoForLocalNuGetFeed path alternativeProjectRoot root + let nupkg = findLocalPackage di.FullName packageName version + + //caches + //|> Seq.iter (fun cache -> + // try + // CopyToCache(cache,nupkg.FullName,force) + // with + // | exn -> + // if verbose then + // traceWarnfn "Could not copy %s to cache %s%s%s" nupkg.FullName cache.Location Environment.NewLine exn.Message) + + File.Copy(nupkg.FullName,targetFileName) + | _ -> // discover the link on the fly let downloadUrl = ref "" try diff --git a/src/Paket.Core/RestoreProcess.fs b/src/Paket.Core/RestoreProcess.fs index 64996806c2..08aa6f6f2e 100644 --- a/src/Paket.Core/RestoreProcess.fs +++ b/src/Paket.Core/RestoreProcess.fs @@ -65,6 +65,7 @@ let ExtractPackage(alternativeProjectRoot, root, groupName, sources, caches, for let overridenFile = FileInfo(Path.Combine(targetDir, "paket.overriden")) let force = if (localOverride || overridenFile.Exists) then true else force let! result = async { + // TODO: Cleanup - Download gets a source and should be able to handle LocalNuGet as well, so this is duplicated match package.Source with | NuGetV2 _ | NuGetV3 _ -> let source = diff --git a/src/Paket.Core/RuntimeGraph.fs b/src/Paket.Core/RuntimeGraph.fs index a1d4e2a774..8bdac94f88 100644 --- a/src/Paket.Core/RuntimeGraph.fs +++ b/src/Paket.Core/RuntimeGraph.fs @@ -195,10 +195,10 @@ module RuntimeGraph = open System.IO /// Downloads the given package into the nuget cache and read its runtime.json. - let getRuntimeGraphFromNugetCache groupName (package:ResolvedPackage) = + let getRuntimeGraphFromNugetCache root groupName (package:ResolvedPackage) = // 1. downloading packages into cache let targetFileName, _ = - NuGetV2.DownloadPackage (None, "C:\FakeRoot", package.Source, [], groupName, package.Name, package.Version, false, false, false) + NuGetV2.DownloadPackage (None, root, package.Source, [], groupName, package.Name, package.Version, false, false, false) |> Async.RunSynchronously let extractedDir = NuGetV2.ExtractPackageToUserFolder (targetFileName, package.Name, package.Version, null) |> Async.RunSynchronously diff --git a/src/Paket.Core/UpdateProcess.fs b/src/Paket.Core/UpdateProcess.fs index 07966a2ef3..69fc8f6827 100644 --- a/src/Paket.Core/UpdateProcess.fs +++ b/src/Paket.Core/UpdateProcess.fs @@ -203,7 +203,7 @@ let SelectiveUpdate(dependenciesFile : DependenciesFile, alternativeProjectRoot, getSha1 getVersionsF (NuGetV2.GetPackageDetails alternativeProjectRoot root force) - (RuntimeGraph.getRuntimeGraphFromNugetCache) + (RuntimeGraph.getRuntimeGraphFromNugetCache root) oldLockFile dependenciesFile updateMode diff --git a/src/Paket/Paket.fsproj b/src/Paket/Paket.fsproj index ab807f987c..ea3424c65f 100644 --- a/src/Paket/Paket.fsproj +++ b/src/Paket/Paket.fsproj @@ -38,7 +38,7 @@ install C:\dev\src\Paket\integrationtests\scenarios\loading-scripts\dependencies-file-flag\temp update - C:\PROJ\Paket\integrationtests\scenarios\i000051-resolve-pessimistic\temp + C:\PROJ\Paket\integrationtests\scenarios\i001494-download\temp pdbonly From 90aada1689ecb8d9daa8ce18742dab02ec196a8d Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Tue, 18 Apr 2017 17:06:30 +0200 Subject: [PATCH 17/30] some cleanup --- src/Paket.Core/Files/ProjectFile.fs | 1 - src/Paket.Core/FrameworkHandling.fs | 17 ----------------- src/Paket.Core/PlatformMatching.fs | 2 -- 3 files changed, 20 deletions(-) diff --git a/src/Paket.Core/Files/ProjectFile.fs b/src/Paket.Core/Files/ProjectFile.fs index 8ce1587483..59b97466bd 100644 --- a/src/Paket.Core/Files/ProjectFile.fs +++ b/src/Paket.Core/Files/ProjectFile.fs @@ -757,7 +757,6 @@ module ProjectFile = |> List.sortBy (fun libFolder -> libFolder.Path) |> List.collect (fun libFolder -> match libFolder with - //| x when (match x.Targets with | [SinglePlatform(Runtimes(_))] -> true | _ -> false) -> [] // TODO: Add reference to custom task instead | _ -> match PlatformMatching.getCondition referenceCondition allTargets libFolder.Targets with | "" -> [] diff --git a/src/Paket.Core/FrameworkHandling.fs b/src/Paket.Core/FrameworkHandling.fs index 6bac93a313..cfb14964af 100644 --- a/src/Paket.Core/FrameworkHandling.fs +++ b/src/Paket.Core/FrameworkHandling.fs @@ -208,7 +208,6 @@ type FrameworkIdentifier = | MonoTouch | MonoMac | Native of BuildMode * Platform - //| Runtimes of string | XamariniOS | XamarinMac | Windows of string @@ -228,7 +227,6 @@ type FrameworkIdentifier = | MonoTouch -> "monotouch" | MonoMac -> "monomac" | Native(_) -> "native" - //| Runtimes(_) -> "runtimes" | XamariniOS -> "xamarinios" | UAP v -> "uap" + v.ShortString() | XamarinMac -> "xamarinmac" @@ -245,7 +243,6 @@ type FrameworkIdentifier = | MonoTouch -> [ ] | MonoMac -> [ ] | Native(_) -> [ ] - //| Runtimes(_) -> [ ] | XamariniOS -> [ ] | XamarinMac -> [ ] | UAP UAPVersion.V10 -> [ ] @@ -307,7 +304,6 @@ type FrameworkIdentifier = | DNXCore _, DNXCore _ -> true | MonoAndroid _, MonoAndroid _ -> true | MonoMac _, MonoMac _ -> true - //| Runtimes _, Runtimes _ -> true | MonoTouch _, MonoTouch _ -> true | Windows _, Windows _ -> true | WindowsPhoneApp _, WindowsPhoneApp _ -> true @@ -368,7 +364,6 @@ module FrameworkDetection = // Each time the parsing is changed, NuGetPackageCache.CurrentCacheVersion should be bumped. let result = match path with - //| x when x.StartsWith "runtimes/" -> Some(Runtimes(x.Substring(9))) | "net10" | "net1" | "10" -> Some (DotNetFramework FrameworkVersion.V1) | "net11" | "11" -> Some (DotNetFramework FrameworkVersion.V1_1) | "net20" | "net2" | "net" | "net20-full" | "net20-client" | "20" -> Some (DotNetFramework FrameworkVersion.V2) @@ -684,20 +679,8 @@ module KnownTargetProfiles = Native(Release,X64) Native(Release,Arm)] - //let AllRuntimes = - // [ Runtimes("win7-x64") - // Runtimes("win7-x86") - // Runtimes("win7-arm") - // Runtimes("debian-x64") - // Runtimes("aot") - // Runtimes("win") - // Runtimes("linux") - // Runtimes("unix") - // Runtimes("osx") ] - let AllProfiles = (AllNativeProfiles |> List.map SinglePlatform) @ - //(AllRuntimes |> List.map SinglePlatform) @ AllDotNetStandardProfiles @ AllDotNetProfiles diff --git a/src/Paket.Core/PlatformMatching.fs b/src/Paket.Core/PlatformMatching.fs index f63682b6f2..2c80e701fa 100644 --- a/src/Paket.Core/PlatformMatching.fs +++ b/src/Paket.Core/PlatformMatching.fs @@ -189,7 +189,6 @@ let getTargetCondition (target:TargetProfile) = | XamarinMac -> "$(TargetFrameworkIdentifier) == 'Xamarin.Mac'", "" | Native(NoBuildMode,NoPlatform) -> "true", "" | Native(NoBuildMode,bits) -> (sprintf "'$(Platform)'=='%s'" bits.AsString), "" - //| Runtimes(platform) -> failwithf "Runtime dependencies are unsupported in project files." | Native(profile,bits) -> (sprintf "'$(Configuration)|$(Platform)'=='%s|%s'" profile.AsString bits.AsString), "" | PortableProfile(name, _) -> sprintf "$(TargetFrameworkProfile) == '%O'" name,"" @@ -232,7 +231,6 @@ let getCondition (referenceCondition:string option) (allTargets: TargetProfile l targets |> List.filter (function | SinglePlatform(Native(NoBuildMode,NoPlatform)) -> false - //| SinglePlatform(Runtimes(_)) -> false | SinglePlatform(DotNetFramework(FrameworkVersion.V4_Client)) -> targets |> List.contains (SinglePlatform(DotNetFramework(FrameworkVersion.V4))) |> not | _ -> true) From db0fe010fc10bc52f9f06ff208e937e2c709881d Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Tue, 18 Apr 2017 17:16:35 +0200 Subject: [PATCH 18/30] update netcore project file :/ --- src/Paket.Core.preview3/Paket.Core.fsproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Paket.Core.preview3/Paket.Core.fsproj b/src/Paket.Core.preview3/Paket.Core.fsproj index 828f055ffd..8744ca25c9 100644 --- a/src/Paket.Core.preview3/Paket.Core.fsproj +++ b/src/Paket.Core.preview3/Paket.Core.fsproj @@ -39,13 +39,13 @@ - + From 80dbd1bf73986d7a27d25bff36ef88045094d906 Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Tue, 18 Apr 2017 18:29:02 +0200 Subject: [PATCH 19/30] add some tests for runtime dependency resolution. --- .../Paket.IntegrationTests/OutdatedSpecs.fs | 2 + src/Paket.Core/Files/DependenciesFile.fs | 2 +- src/Paket.Core/RuntimeGraph.fs | 3 +- .../Lockfile/GenerateAuthModeSpecs.fs | 7 +- .../Lockfile/GenerateWithOptionsSpecs.fs | 22 ++--- tests/Paket.Tests/Lockfile/GeneratorSpecs.fs | 7 +- tests/Paket.Tests/Resolver/StrategySpecs.fs | 13 +-- tests/Paket.Tests/RuntimeGraphTests.fs | 82 ++++++++++++++++++- tests/Paket.Tests/TestHelpers.fs | 33 ++++++-- tests/Paket.Tests/UpdateProcessSpecs.fs | 2 +- 10 files changed, 139 insertions(+), 34 deletions(-) diff --git a/integrationtests/Paket.IntegrationTests/OutdatedSpecs.fs b/integrationtests/Paket.IntegrationTests/OutdatedSpecs.fs index 04f621512f..13e77e4716 100644 --- a/integrationtests/Paket.IntegrationTests/OutdatedSpecs.fs +++ b/integrationtests/Paket.IntegrationTests/OutdatedSpecs.fs @@ -15,12 +15,14 @@ let ``#183 outdated without params``() = msg |> shouldContainText "FSharp.Formatting 2.4 ->" [] +[] // PATH TOO LONG on Windows... let ``#183 outdated --ignore-constraint``() = let msg = paket "outdated --ignore-constraints" "i000183-outdated-with-special-parameters" msg.Contains("Newtonsoft.Json 6.0.7 -> 6.0.8") |> shouldEqual false [] +[] // PATH TOO LONG on Windows... let ``#183 outdated --include-prereleases``() = let msg = paket "outdated --include-prereleases" "i000183-outdated-with-special-parameters" msg |> shouldContainText "Newtonsoft.Json 6.0.7 ->" diff --git a/src/Paket.Core/Files/DependenciesFile.fs b/src/Paket.Core/Files/DependenciesFile.fs index 84c823b615..249071e990 100644 --- a/src/Paket.Core/Files/DependenciesFile.fs +++ b/src/Paket.Core/Files/DependenciesFile.fs @@ -279,7 +279,7 @@ type DependenciesFile(fileName,groups:Map, textRepr | _ -> resolution | Resolution.Conflict _ -> resolution - { ResolvedPackages = resolution + { ResolvedPackages = runtimeResolution ResolvedSourceFiles = remoteFiles } groupsToResolve diff --git a/src/Paket.Core/RuntimeGraph.fs b/src/Paket.Core/RuntimeGraph.fs index 8bdac94f88..227adc26b1 100644 --- a/src/Paket.Core/RuntimeGraph.fs +++ b/src/Paket.Core/RuntimeGraph.fs @@ -188,7 +188,8 @@ module RuntimeGraph = |> Seq.choose (fun r -> match g.Runtimes |> Map.tryFind r with | Some desc -> - desc.RuntimeDependencies |> Map.tryFind packageName + let result = desc.RuntimeDependencies |> Map.tryFind packageName + result | None -> None) |> Seq.tryHead |> Option.defaultValue [] diff --git a/tests/Paket.Tests/Lockfile/GenerateAuthModeSpecs.fs b/tests/Paket.Tests/Lockfile/GenerateAuthModeSpecs.fs index 4c28494f73..796abb24ec 100644 --- a/tests/Paket.Tests/Lockfile/GenerateAuthModeSpecs.fs +++ b/tests/Paket.Tests/Lockfile/GenerateAuthModeSpecs.fs @@ -12,9 +12,10 @@ source "http://www.nuget.org/api/v2" username: "user" password: "pass" nuget "Castle.Windsor-log4net" "~> 3.2" """ -let graph = [ - "Castle.Windsor-log4net","3.2",[] -] +let graph = + OfSimpleGraph [ + "Castle.Windsor-log4net","3.2",[] + ] let expected = """NUGET remote: http://www.nuget.org/api/v2 diff --git a/tests/Paket.Tests/Lockfile/GenerateWithOptionsSpecs.fs b/tests/Paket.Tests/Lockfile/GenerateWithOptionsSpecs.fs index 03e879fb9f..eb6e9735e5 100644 --- a/tests/Paket.Tests/Lockfile/GenerateWithOptionsSpecs.fs +++ b/tests/Paket.Tests/Lockfile/GenerateWithOptionsSpecs.fs @@ -16,9 +16,10 @@ source "http://www.nuget.org/api/v2" nuget "Castle.Windsor-log4net" "~> 3.2" """ -let graph1 = [ - "Castle.Windsor-log4net","3.2",[] -] +let graph1 = + OfSimpleGraph [ + "Castle.Windsor-log4net","3.2",[] + ] let expected1 = """REFERENCES: STRICT COPY-LOCAL: FALSE @@ -43,9 +44,10 @@ source "http://www.nuget.org/api/v2" nuget "Microsoft.SqlServer.Types" """ -let graph2 = [ - "Microsoft.SqlServer.Types","1.0",[] -] +let graph2 = + OfSimpleGraph [ + "Microsoft.SqlServer.Types","1.0",[] + ] let expected2 = """IMPORT-TARGETS: FALSE CONTENT: NONE @@ -67,9 +69,10 @@ source "http://www.nuget.org/api/v2" nuget "Microsoft.SqlServer.Types" """ -let graph3 = [ - "Microsoft.SqlServer.Types","1.0",[] -] +let graph3 = + OfSimpleGraph [ + "Microsoft.SqlServer.Types","1.0",[] + ] let expected3 = """REDIRECTS: ON NUGET @@ -178,7 +181,6 @@ nuget NLog.Contrib "NLog.Contrib","1.0.0",["NLog",DependenciesFileParser.parseVersionRequirement ">= 1.0.1"] ] - let expected = """FRAMEWORK: >= NET40 NUGET remote: https://www.nuget.org/api/v2 diff --git a/tests/Paket.Tests/Lockfile/GeneratorSpecs.fs b/tests/Paket.Tests/Lockfile/GeneratorSpecs.fs index dd04c005cb..d4e2289075 100644 --- a/tests/Paket.Tests/Lockfile/GeneratorSpecs.fs +++ b/tests/Paket.Tests/Lockfile/GeneratorSpecs.fs @@ -197,9 +197,10 @@ source https://www.myget.org/F/ravendb3/ nuget RavenDB.Client == 3.0.3498-Unstable """ -let graph2 = [ - "RavenDB.Client","3.0.3498-Unstable",[] -] +let graph2 = + OfSimpleGraph [ + "RavenDB.Client","3.0.3498-Unstable",[] + ] let expected2 = """NUGET remote: https://www.myget.org/F/ravendb3 diff --git a/tests/Paket.Tests/Resolver/StrategySpecs.fs b/tests/Paket.Tests/Resolver/StrategySpecs.fs index 4764ab80d0..c353582831 100644 --- a/tests/Paket.Tests/Resolver/StrategySpecs.fs +++ b/tests/Paket.Tests/Resolver/StrategySpecs.fs @@ -67,12 +67,13 @@ source "http://www.nuget.org/api/v2" nuget Microsoft.AspNet.Mvc >= 6.0.0 lowest_matching: true """ -let graph2 = [ - "Microsoft.AspNet.Mvc","6.0.0",[] - "Microsoft.AspNet.Mvc","6.0.1",[] - "Microsoft.AspNet.Mvc","6.0.13",[] - "Microsoft.AspNet.Mvc","5.2.3",[] -] +let graph2 = + OfSimpleGraph [ + "Microsoft.AspNet.Mvc","6.0.0",[] + "Microsoft.AspNet.Mvc","6.0.1",[] + "Microsoft.AspNet.Mvc","6.0.13",[] + "Microsoft.AspNet.Mvc","5.2.3",[] + ] [] let ``should resolve config with min requirement``() = diff --git a/tests/Paket.Tests/RuntimeGraphTests.fs b/tests/Paket.Tests/RuntimeGraphTests.fs index 966ac72f02..91e6275a3d 100644 --- a/tests/Paket.Tests/RuntimeGraphTests.fs +++ b/tests/Paket.Tests/RuntimeGraphTests.fs @@ -4,6 +4,7 @@ open Paket open NUnit.Framework open FsUnit open Paket.Domain +open Paket.TestHelpers let supportAndDeps = """ { @@ -109,4 +110,83 @@ let ``Check if we can merge two graphs``() = |> shouldEqual ([ PackageName "Microsoft.Win32.Primitives", [ PackageName "runtime.win.Microsoft.Win32.Primitives", VersionRequirement.VersionRequirement (VersionRange.Minimum (SemVer.Parse "4.3.0"), PreReleaseStatus.No) ] PackageName "System.Runtime.Extensions", [ PackageName "runtime.win.System.Runtime.Extensions", VersionRequirement.VersionRequirement (VersionRange.Minimum (SemVer.Parse "4.3.0"), PreReleaseStatus.No) ] - ] |> Map.ofSeq) \ No newline at end of file + ] |> Map.ofSeq) + +[] +let ``Check that runtime dependencies are saved as such in the lockfile`` () = + let lockFileData = """ """ + let getLockFile lockFileData = LockFile.Parse("",toLines lockFileData) + let lockFile = lockFileData |> getLockFile + + let graph = + [ "MyDependency", "3.2.0", [], RuntimeGraph.Empty + "MyDependency", "3.3.3", [], RuntimeGraph.Empty + "MyDependency", "4.0.0", [], RuntimeGraphParser.readRuntimeGraph """{ + "runtimes": { + "win": { + "MyDependency": { + "MyRuntimeDependency": "4.0.0" + } + } + } +}""" + "MyRuntimeDependency", "4.0.0", [], RuntimeGraph.Empty + "MyRuntimeDependency", "4.0.1", [], RuntimeGraph.Empty ] + |> OfGraphWithRuntimeDeps + + let depsFile = DependenciesFile.FromCode("""source http://www.nuget.org/api/v2 +nuget MyDependency""") + let lockFile, resolution = + UpdateProcess.selectiveUpdate true noSha1 (VersionsFromGraph graph) (PackageDetailsFromGraph graph) (GetRuntimeGraphFromGraph graph) lockFile depsFile PackageResolver.UpdateMode.Install SemVerUpdateMode.NoRestriction + + let result = + lockFile.GetGroupedResolution() + |> Seq.map (fun (KeyValue (_,resolved)) -> (string resolved.Name, string resolved.Version, resolved.IsRuntimeDependency)) + + let expected = + [("MyDependency","4.0.0", false); + ("MyRuntimeDependency","4.0.1", true)] + |> Seq.sortBy (fun (t,_,_) ->t) + + result + |> Seq.sortBy (fun (t,_,_) ->t) + |> shouldEqual expected + +[] +let ``Check that runtime dependencies we don't use are ignored`` () = + let lockFileData = """ """ + let getLockFile lockFileData = LockFile.Parse("",toLines lockFileData) + let lockFile = lockFileData |> getLockFile + + let graph = + [ "MyDependency", "3.2.0", [], RuntimeGraph.Empty + "MyDependency", "3.3.3", [], RuntimeGraph.Empty + "MyDependency", "4.0.0", [], RuntimeGraphParser.readRuntimeGraph """{ + "runtimes": { + "win": { + "SomePackage": { + "MyRuntimeDependency": "4.0.0" + } + } + } +}""" + "MyRuntimeDependency", "4.0.0", [], RuntimeGraph.Empty + "MyRuntimeDependency", "4.0.1", [], RuntimeGraph.Empty ] + |> OfGraphWithRuntimeDeps + + let depsFile = DependenciesFile.FromCode("""source http://www.nuget.org/api/v2 +nuget MyDependency""") + let lockFile, resolution = + UpdateProcess.selectiveUpdate true noSha1 (VersionsFromGraph graph) (PackageDetailsFromGraph graph) (GetRuntimeGraphFromGraph graph) lockFile depsFile PackageResolver.UpdateMode.Install SemVerUpdateMode.NoRestriction + + let result = + lockFile.GetGroupedResolution() + |> Seq.map (fun (KeyValue (_,resolved)) -> (string resolved.Name, string resolved.Version, resolved.IsRuntimeDependency)) + + let expected = + [("MyDependency","4.0.0", false)] + |> Seq.sortBy (fun (t,_,_) ->t) + + result + |> Seq.sortBy (fun (t,_,_) ->t) + |> shouldEqual expected \ No newline at end of file diff --git a/tests/Paket.Tests/TestHelpers.fs b/tests/Paket.Tests/TestHelpers.fs index 67069834bb..3f65b84a5f 100644 --- a/tests/Paket.Tests/TestHelpers.fs +++ b/tests/Paket.Tests/TestHelpers.fs @@ -11,32 +11,39 @@ open Paket.Domain type GraphDependency = string * VersionRequirement * FrameworkRestrictions -type DependencyGraph = list +type DependencyGraph = list let OfSimpleGraph (g:seq) : DependencyGraph = g |> Seq.map (fun (x, y, (rqs)) -> - x, y, rqs |> List.map (fun (a,b) -> (a, b, FrameworkRestrictionList []))) + x, y, rqs |> List.map (fun (a,b) -> (a, b, FrameworkRestrictionList [])), RuntimeGraph.Empty) |> Seq.toList let OfGraphWithRestriction (g:seq) : DependencyGraph = g |> Seq.map (fun (x, y, (rqs)) -> - x, y, rqs |> List.map (fun (a,b,c) -> (a, b, c))) + x, y, rqs |> List.map (fun (a,b,c) -> (a, b, c)), RuntimeGraph.Empty) |> Seq.toList let GraphOfNuspecs (g:seq) : DependencyGraph = g |> Seq.map (fun nuspecText -> let nspec = Nuspec.Load("in-memory", nuspecText) - nspec.OfficialName, nspec.Version, nspec.Dependencies |> List.map (fun (a,b,c) -> a.GetCompareString(), b, c)) + nspec.OfficialName, nspec.Version, nspec.Dependencies |> List.map (fun (a,b,c) -> a.GetCompareString(), b, c), RuntimeGraph.Empty) |> Seq.toList +let OfGraphWithRuntimeDeps (g:seq) : DependencyGraph = + g + |> Seq.map (fun (x, y, rqs, run) -> + x, y, rqs |> List.map (fun (a,b) -> (a, b, FrameworkRestrictionList [])), run) + |> Seq.toList + + let PackageDetailsFromGraph (graph : DependencyGraph) sources groupName (package:PackageName) (version:SemVerInfo) = let name,dependencies = graph - |> Seq.filter (fun (p, v, _) -> (PackageName p) = package && SemVer.Parse v = version) - |> Seq.map (fun (n, _, d) -> PackageName n,d |> List.map (fun (x,y,z) -> PackageName x,y,z)) + |> Seq.filter (fun (p, v, _, _) -> (PackageName p) = package && SemVer.Parse v = version) + |> Seq.map (fun (n, _, d, _) -> PackageName n,d |> List.map (fun (x,y,z) -> PackageName x,y,z)) |> Seq.head { Name = name @@ -49,8 +56,8 @@ let PackageDetailsFromGraph (graph : DependencyGraph) sources groupName (package let VersionsFromGraph (graph : DependencyGraph) sources resolverStrategy groupName packageName = let versions = graph - |> Seq.filter (fun (p, _, _) -> (PackageName p) = packageName) - |> Seq.map (fun (_, v, _) -> SemVer.Parse v) + |> Seq.filter (fun (p, _, _, _) -> (PackageName p) = packageName) + |> Seq.map (fun (_, v, _, _) -> SemVer.Parse v) |> Seq.toList |> List.map (fun v -> v,sources) @@ -58,6 +65,16 @@ let VersionsFromGraph (graph : DependencyGraph) sources resolverStrategy groupNa | ResolverStrategy.Max -> List.sortDescending versions | ResolverStrategy.Min -> List.sort versions +let GetRuntimeGraphFromGraph (graph : DependencyGraph) groupName (package:ResolvedPackage) = + graph + |> Seq.filter (fun (p, v, _, r) -> (PackageName p) = package.Name && SemVer.Parse v = package.Version) + |> Seq.map (fun (_, _, _, r) -> r) + |> RuntimeGraph.mergeSeq + // Properly returning None here makes the tests datastructures unneccessary complex. + // It doesn't really matter because Empty is used anyway if all return "None", which is the same as merging a lot of Emtpy graphs... + |> Some + + let VersionsFromGraphAsSeq (graph : DependencyGraph) sources resolverStrategy groupName packageName = VersionsFromGraph graph sources resolverStrategy groupName packageName |> Seq.ofList diff --git a/tests/Paket.Tests/UpdateProcessSpecs.fs b/tests/Paket.Tests/UpdateProcessSpecs.fs index f6883c54a2..f4b1ef4305 100644 --- a/tests/Paket.Tests/UpdateProcessSpecs.fs +++ b/tests/Paket.Tests/UpdateProcessSpecs.fs @@ -46,7 +46,7 @@ let getLockFile lockFileData = LockFile.Parse("",toLines lockFileData) let lockFile = lockFileData |> getLockFile let selectiveUpdateFromGraph graph force lockFile depsFile updateMode restriction = - selectiveUpdate force noSha1 (VersionsFromGraph graph) (PackageDetailsFromGraph graph) (fun _ _ -> None) lockFile depsFile updateMode restriction + selectiveUpdate force noSha1 (VersionsFromGraph graph) (PackageDetailsFromGraph graph) (GetRuntimeGraphFromGraph graph) lockFile depsFile updateMode restriction [] let ``SelectiveUpdate does not update any package when it is neither updating all nor selective updating``() = From 88b2430e46e77d9bf76abb64dba8d9789c861919 Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Tue, 18 Apr 2017 19:21:09 +0200 Subject: [PATCH 20/30] add runtime dependencies to the lockfile and mark them with 'isRuntimeDependency: true' --- src/Paket.Core/Files/LockFile.fs | 23 +++++++++++++++----- src/Paket.Core/RestoreProcess.fs | 2 +- tests/Paket.Tests/RuntimeGraphTests.fs | 29 ++++++++++++++++++++++++++ tests/Paket.Tests/TestHelpers.fs | 7 +++++-- 4 files changed, 53 insertions(+), 8 deletions(-) diff --git a/src/Paket.Core/Files/LockFile.fs b/src/Paket.Core/Files/LockFile.fs index bc0c3e5fec..fba5245867 100644 --- a/src/Paket.Core/Files/LockFile.fs +++ b/src/Paket.Core/Files/LockFile.fs @@ -107,7 +107,12 @@ module LockFileSerializer = { package.Settings with FrameworkRestrictions = FrameworkRestrictionList [] } else package.Settings - let s = settings.ToString().ToLower() + let s = + // add "isRuntimeDependency" + match package.IsRuntimeDependency, settings.ToString().ToLower() with + | true, "" -> "isRuntimeDependency: true" + | true, s -> s + ", isRuntimeDependency: true" + | _, s -> s if s = "" then yield sprintf " %O %s" package.Name versionStr @@ -359,7 +364,14 @@ module LockFileParser = ("framework: " + parts.[1]) else parts.[1] - parts.[0],InstallSettings.Parse(optionsString) + let isRuntimeDependency, optionsString = + if optionsString.EndsWith ", isRuntimeDependency: true" then + true, optionsString.Substring(0, optionsString.Length - ", isRuntimeDependency: true".Length) + elif optionsString.EndsWith "isRuntimeDependency: true" then + assert (optionsString = "isRuntimeDependency: true") + true, "" + else false, optionsString + parts.[0],isRuntimeDependency,InstallSettings.Parse(optionsString) ([{ GroupName = Constants.MainDependencyGroup; RepositoryType = None; RemoteUrl = None; Packages = []; SourceFiles = []; Options = InstallOptions.Default; LastWasPackage = false }], lockFileLines) ||> Seq.fold(fun state line -> @@ -394,7 +406,7 @@ module LockFileParser = | NugetPackage details -> match currentGroup.RemoteUrl with | Some remote -> - let package,settings = parsePackage details + let package,isRuntimeDependency,settings = parsePackage details let parts' = package.Split ' ' let version = if parts'.Length < 2 then @@ -411,10 +423,11 @@ module LockFileParser = Settings = settings Version = SemVer.Parse version // TODO: write stuff into the lockfile and read it here - IsRuntimeDependency = false } :: currentGroup.Packages }::otherGroups + IsRuntimeDependency = isRuntimeDependency } :: currentGroup.Packages }::otherGroups | None -> failwith "no source has been specified." | NugetDependency (name, v, frameworkSettings) -> - let version,settings = parsePackage v + let version,isRuntimeDependency,settings = parsePackage v + assert (not isRuntimeDependency) if currentGroup.LastWasPackage then match currentGroup.Packages with | currentPackage :: otherPackages -> diff --git a/src/Paket.Core/RestoreProcess.fs b/src/Paket.Core/RestoreProcess.fs index 08aa6f6f2e..9b286ead67 100644 --- a/src/Paket.Core/RestoreProcess.fs +++ b/src/Paket.Core/RestoreProcess.fs @@ -110,7 +110,7 @@ let internal restore (alternativeProjectRoot, root, groupName, sources, caches, async { RemoteDownload.DownloadSourceFiles(Path.GetDirectoryName lockFile.FileName, groupName, force, lockFile.Groups.[groupName].RemoteFiles) let! _ = lockFile.Groups.[groupName].Resolution - |> Map.filter (fun name _ -> packages.Contains name) + |> Map.filter (fun name r -> packages.Contains name) |> Seq.map (fun kv -> ExtractPackage(alternativeProjectRoot, root, groupName, sources, caches, force, kv.Value, Set.contains kv.Key overriden)) |> Async.Parallel return () diff --git a/tests/Paket.Tests/RuntimeGraphTests.fs b/tests/Paket.Tests/RuntimeGraphTests.fs index 91e6275a3d..f308d3b980 100644 --- a/tests/Paket.Tests/RuntimeGraphTests.fs +++ b/tests/Paket.Tests/RuntimeGraphTests.fs @@ -134,6 +134,11 @@ let ``Check that runtime dependencies are saved as such in the lockfile`` () = "MyRuntimeDependency", "4.0.1", [], RuntimeGraph.Empty ] |> OfGraphWithRuntimeDeps + let expectedLockFile = """NUGET + remote: http://www.nuget.org/api/v2 + MyDependency (4.0) + MyRuntimeDependency (4.0.1) - isRuntimeDependency: true""" + let depsFile = DependenciesFile.FromCode("""source http://www.nuget.org/api/v2 nuget MyDependency""") let lockFile, resolution = @@ -152,6 +157,10 @@ nuget MyDependency""") |> Seq.sortBy (fun (t,_,_) ->t) |> shouldEqual expected + lockFile.GetGroup(Constants.MainDependencyGroup).Resolution + |> LockFileSerializer.serializePackages depsFile.Groups.[Constants.MainDependencyGroup].Options + |> shouldEqual (normalizeLineEndings expectedLockFile) + [] let ``Check that runtime dependencies we don't use are ignored`` () = let lockFileData = """ """ @@ -189,4 +198,24 @@ nuget MyDependency""") result |> Seq.sortBy (fun (t,_,_) ->t) + |> shouldEqual expected + +[] +let ``Check that runtime dependencies are loaded from the lockfile`` () = + let lockFile = """NUGET + remote: http://www.nuget.org/api/v2 + MyDependency (4.0) + MyRuntimeDependency (4.0.1) - isRuntimeDependency: true""" + + let lockFile = LockFileParser.Parse(toLines lockFile) |> List.head + let packages = List.rev lockFile.Packages + + let expected = + [("MyDependency","4.0", false); + ("MyRuntimeDependency","4.0.1", true)] + |> List.sortBy (fun (t,_,_) ->t) + + packages + |> List.map (fun r -> string r.Name, string r.Version, r.IsRuntimeDependency) + |> List.sortBy (fun (t,_,_) ->t) |> shouldEqual expected \ No newline at end of file diff --git a/tests/Paket.Tests/TestHelpers.fs b/tests/Paket.Tests/TestHelpers.fs index 3f65b84a5f..dcea6113bc 100644 --- a/tests/Paket.Tests/TestHelpers.fs +++ b/tests/Paket.Tests/TestHelpers.fs @@ -98,9 +98,12 @@ let safeResolve graph (dependencies : (string * VersionRange) list) = let resolve graph dependencies = (safeResolve graph dependencies).GetModelOrFail() -let ResolveWithGraph(dependenciesFile:DependenciesFile,getSha1,getVersionsF, getPackageDetailsF) = +let ResolveWithGraphR(dependenciesFile:DependenciesFile,getSha1,getVersionsF, getPackageDetailsF, getRuntimeGraph) = let groups = [Constants.MainDependencyGroup, None ] |> Map.ofSeq - dependenciesFile.Resolve(true,getSha1,getVersionsF,getPackageDetailsF,(fun _ _ -> None),groups,UpdateMode.UpdateAll) + dependenciesFile.Resolve(true,getSha1,getVersionsF,getPackageDetailsF,getRuntimeGraph,groups,UpdateMode.UpdateAll) + +let ResolveWithGraph(dependenciesFile:DependenciesFile,getSha1,getVersionsF, getPackageDetailsF) = + ResolveWithGraphR(dependenciesFile,getSha1,getVersionsF, getPackageDetailsF, (fun _ _ -> None)) let getVersion (resolved:ResolvedPackage) = resolved.Version.ToString() From d717814ddb8f89fd1e947dcd6bf2eeaf015f3ee0 Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Tue, 18 Apr 2017 19:34:06 +0200 Subject: [PATCH 21/30] move InstallModel.fs after RuntimeGraph.fs as we will shortly depend on it... --- src/Paket.Core.preview3/Paket.Core.fsproj | 2 +- src/Paket.Core/InstallModel.fs | 5 +---- src/Paket.Core/NuGetV2.fs | 9 --------- src/Paket.Core/Nuget.fs | 5 +++++ src/Paket.Core/Paket.Core.fsproj | 2 +- tests/Paket.Tests/InstallModel/ProcessingSpecs.fs | 2 +- 6 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/Paket.Core.preview3/Paket.Core.fsproj b/src/Paket.Core.preview3/Paket.Core.fsproj index 8744ca25c9..3d51959edf 100644 --- a/src/Paket.Core.preview3/Paket.Core.fsproj +++ b/src/Paket.Core.preview3/Paket.Core.fsproj @@ -39,13 +39,13 @@ - + diff --git a/src/Paket.Core/InstallModel.fs b/src/Paket.Core/InstallModel.fs index a0880dd76d..3dd357c9f0 100644 --- a/src/Paket.Core/InstallModel.fs +++ b/src/Paket.Core/InstallModel.fs @@ -7,10 +7,7 @@ open Paket.Requirements open Logging open PlatformMatching -// 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 } +type UnparsedPackageFile = Paket.NuGet.UnparsedPackageFile [] type Reference = diff --git a/src/Paket.Core/NuGetV2.fs b/src/Paket.Core/NuGetV2.fs index 8b74ae9acc..e47d0104c4 100644 --- a/src/Paket.Core/NuGetV2.fs +++ b/src/Paket.Core/NuGetV2.fs @@ -946,15 +946,6 @@ let DownloadPackage(alternativeProjectRoot, root, (source : PackageSource), cach let di = Utils.getDirectoryInfoForLocalNuGetFeed path alternativeProjectRoot root let nupkg = findLocalPackage di.FullName packageName version - //caches - //|> Seq.iter (fun cache -> - // try - // CopyToCache(cache,nupkg.FullName,force) - // with - // | exn -> - // if verbose then - // traceWarnfn "Could not copy %s to cache %s%s%s" nupkg.FullName cache.Location Environment.NewLine exn.Message) - File.Copy(nupkg.FullName,targetFileName) | _ -> // discover the link on the fly diff --git a/src/Paket.Core/Nuget.fs b/src/Paket.Core/Nuget.fs index af006906c8..1760b54e7e 100644 --- a/src/Paket.Core/Nuget.fs +++ b/src/Paket.Core/Nuget.fs @@ -12,6 +12,11 @@ open Chessie.ErrorHandling open Newtonsoft.Json open System +// 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 } + module NuGetConfig = open System.Text diff --git a/src/Paket.Core/Paket.Core.fsproj b/src/Paket.Core/Paket.Core.fsproj index b6ba85886d..01dbf88423 100644 --- a/src/Paket.Core/Paket.Core.fsproj +++ b/src/Paket.Core/Paket.Core.fsproj @@ -117,13 +117,13 @@ - + diff --git a/tests/Paket.Tests/InstallModel/ProcessingSpecs.fs b/tests/Paket.Tests/InstallModel/ProcessingSpecs.fs index cd9266cbe7..f177750a2a 100644 --- a/tests/Paket.Tests/InstallModel/ProcessingSpecs.fs +++ b/tests/Paket.Tests/InstallModel/ProcessingSpecs.fs @@ -13,7 +13,7 @@ let fromLegacyList (prefix:string) l = l |> List.map (fun (i:string) -> if i.StartsWith prefix then - { FullPath = i; PathWithinPackage = i.Substring(prefix.Length).Replace("\\", "/") } + { Paket.NuGet.UnparsedPackageFile.FullPath = i; Paket.NuGet.UnparsedPackageFile.PathWithinPackage = i.Substring(prefix.Length).Replace("\\", "/") } else failwithf "Expected '%s' to start with '%s'" i prefix) [] From 5b50f8e25496d1efabe8b1662de00aafaf81961f Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Tue, 18 Apr 2017 23:52:00 +0200 Subject: [PATCH 22/30] cleanup InstallModel again and prepare for runtime support... --- src/Paket.Core/BindingRedirects.fs | 10 +- src/Paket.Core/Files/ProjectFile.fs | 166 ++++--- src/Paket.Core/InstallModel.fs | 398 ++++++++-------- src/Paket.Core/InstallProcess.fs | 14 +- src/Paket.Core/RuntimeGraph.fs | 1 + src/Paket.Core/ScriptGeneration.fs | 16 +- .../InstallModel/ProcessingSpecs.fs | 447 ++++++++++++------ .../InstallModel/Xml/LibGit2Sharp.fs | 3 +- .../InstallModel/Xml/Microsoft.Bcl.Build.fs | 3 +- .../InstallModel/Xml/StyleCop.MSBuild.fs | 3 +- 10 files changed, 598 insertions(+), 463 deletions(-) diff --git a/src/Paket.Core/BindingRedirects.fs b/src/Paket.Core/BindingRedirects.fs index c3b1e7f20b..5bb3eb219e 100644 --- a/src/Paket.Core/BindingRedirects.fs +++ b/src/Paket.Core/BindingRedirects.fs @@ -130,7 +130,7 @@ let private addConfigFileToProject project = project.Save(false)) /// Applies a set of binding redirects to a single configuration file. -let private applyBindingRedirects isFirstGroup cleanBindingRedirects (allKnownLibs:Reference seq) bindingRedirects (configFilePath:string) = +let private applyBindingRedirects isFirstGroup cleanBindingRedirects (allKnownLibNames:string seq) bindingRedirects (configFilePath:string) = let config = try XDocument.Load(configFilePath, LoadOptions.PreserveWhitespace) @@ -147,9 +147,9 @@ let private applyBindingRedirects isFirstGroup cleanBindingRedirects (allKnownLi let libIsContained e = let haystack = e.ToString().ToLower() - allKnownLibs + allKnownLibNames |> Seq.exists (fun b -> - let needle = (sprintf "name=\"%s\"" b.ReferenceName).ToLower() + let needle = (sprintf "name=\"%s\"" b).ToLower() haystack.Contains needle) let nsManager = XmlNamespaceManager(NameTable()); @@ -169,7 +169,7 @@ let private applyBindingRedirects isFirstGroup cleanBindingRedirects (allKnownLi config.Save(f, SaveOptions.DisableFormatting) /// Applies a set of binding redirects to all .config files in a specific folder. -let applyBindingRedirectsToFolder isFirstGroup createNewBindingFiles cleanBindingRedirects rootPath allKnownLibs bindingRedirects = +let applyBindingRedirectsToFolder isFirstGroup createNewBindingFiles cleanBindingRedirects rootPath allKnownLibNames bindingRedirects = let applyBindingRedirects projectFile = let bindingRedirects = bindingRedirects projectFile |> Seq.toList let path = Path.GetDirectoryName projectFile.FileName @@ -182,7 +182,7 @@ let applyBindingRedirectsToFolder isFirstGroup createNewBindingFiles cleanBindin addConfigFileToProject projectFile Some config | _ -> None - |> Option.iter (applyBindingRedirects isFirstGroup cleanBindingRedirects allKnownLibs bindingRedirects) + |> Option.iter (applyBindingRedirects isFirstGroup cleanBindingRedirects allKnownLibNames bindingRedirects) rootPath |> getProjectFilesWithPaketReferences Directory.GetFiles diff --git a/src/Paket.Core/Files/ProjectFile.fs b/src/Paket.Core/Files/ProjectFile.fs index 59b97466bd..fd2dfebbed 100644 --- a/src/Paket.Core/Files/ProjectFile.fs +++ b/src/Paket.Core/Files/ProjectFile.fs @@ -599,9 +599,10 @@ module ProjectFile = deleteIfEmpty "Choose" project |> ignore let getCustomModelNodes(model:InstallModel) (project:ProjectFile) = - let libs = - model.GetLibReferencesLazy.Force() - |> Set.map (fun lib -> lib.ReferenceName) + let libs : string Set = + (model.GetAllLegacyReferenceAndFrameworkReferenceNames()) + //model.GetLibReferencesLazy.Force() + //|> Set.map (fun lib -> lib.ReferenceName) getCustomReferenceAndFrameworkNodes project |> List.filter (fun node -> @@ -671,71 +672,65 @@ module ProjectFile = |> Set.ofList let model = model.FilterReferences references - let createItemGroup (targets:TargetProfile list) references = + let createItemGroup (targets:TargetProfile list) (frameworkReferences:FrameworkReference list) (libraries:Library list) = let itemGroup = createNode "ItemGroup" project - let refOrder (r:Reference) = - match r with - | Reference.FrameworkAssemblyReference _ -> 0 - | Reference.Library _ -> 1 - | _ -> 2 - - for lib in references |> List.sortBy(fun (r:Reference) -> refOrder r, r.ReferenceName) do - match lib with - | Reference.Library lib -> - let fi = FileInfo (normalizePath lib) - let aliases = - aliases - |> Map.tryPick (fun dll alias -> if fi.Name.Equals(dll, StringComparison.OrdinalIgnoreCase) then Some(alias) else None) - - let relativePath = createRelativePath project.FileName fi.FullName - let privateSettings = - match copyLocal with - | Some true -> "True" - | Some false -> "False" - | None -> if relativePath.Contains @"\ref\" then "False" else "True" - - if relativePath.Contains @"\native\" then createNode "NativeReference" project else createNode "Reference" project - |> addAttribute "Include" (fi.Name.Replace(fi.Extension,"")) - |> addChild (createNodeSet "HintPath" relativePath project) - |> addChild (createNodeSet "Private" privateSettings project) - |> addChild (createNodeSet "Paket" "True" project) - |> fun n -> - match aliases with - | None -> n - | Some alias -> addChild (createNodeSet "Aliases" alias project) n - |> itemGroup.AppendChild - |> ignore - | Reference.FrameworkAssemblyReference frameworkAssembly -> - createNode "Reference" project - |> addAttribute "Include" frameworkAssembly - |> addChild (createNodeSet "Paket" "True" project) - |> itemGroup.AppendChild - |> ignore - | Reference.TargetsFile _ -> () + //let refOrder (r:Reference) = + // match r with + // | Reference.FrameworkAssemblyReference _ -> 0 + // | Reference.Library _ -> 1 + // | _ -> 2 + for ref in frameworkReferences |> List.sortBy (fun f -> f.Name) do + createNode "Reference" project + |> addAttribute "Include" ref.Name + |> addChild (createNodeSet "Paket" "True" project) + |> itemGroup.AppendChild + |> ignore + for lib in libraries |> List.sortBy (fun f -> f.Name) do + let fi = FileInfo (normalizePath lib.Path) + let aliases = + aliases + |> Map.tryPick (fun dll alias -> if fi.Name.Equals(dll, StringComparison.OrdinalIgnoreCase) then Some(alias) else None) + + let relativePath = createRelativePath project.FileName fi.FullName + let privateSettings = + match copyLocal with + | Some true -> "True" + | Some false -> "False" + | None -> if relativePath.Contains @"\ref\" then "False" else "True" + + if relativePath.Contains @"\native\" then createNode "NativeReference" project else createNode "Reference" project + |> addAttribute "Include" (fi.Name.Replace(fi.Extension,"")) + |> addChild (createNodeSet "HintPath" relativePath project) + |> addChild (createNodeSet "Private" privateSettings project) + |> addChild (createNodeSet "Paket" "True" project) + |> fun n -> + match aliases with + | None -> n + | Some alias -> addChild (createNodeSet "Aliases" alias project) n + |> itemGroup.AppendChild + |> ignore + itemGroup - let createPropertyGroup references = + let createPropertyGroup (references:MsBuildFile list) = let propertyGroup = createNode "PropertyGroup" project let propertyNames = references - |> Seq.choose (fun lib -> - match lib with - | Reference.Library _ -> None - | Reference.FrameworkAssemblyReference _ -> None - | Reference.TargetsFile targetsFile -> - let fi = new FileInfo(normalizePath targetsFile) - let propertyName = "__paket__" + fi.Name.ToString().Replace(" ","_").Replace(".","_") - - let path = createRelativePath project.FileName (fi.FullName.Replace(fi.Extension,"")) - let s = path.Substring(path.LastIndexOf("build\\") + 6) - let node = createNode propertyName project - node.InnerText <- s - node - |> propertyGroup.AppendChild - |> ignore - Some(propertyName,createRelativePath project.FileName fi.FullName,path.Substring(0,path.LastIndexOf("build\\") + 6))) + |> Seq.map (fun lib -> + let targetsFile = lib.Path + let fi = new FileInfo(normalizePath targetsFile) + let propertyName = "__paket__" + fi.Name.ToString().Replace(" ","_").Replace(".","_") + + let path = createRelativePath project.FileName (fi.FullName.Replace(fi.Extension,"")) + let s = path.Substring(path.LastIndexOf("build\\") + 6) + let node = createNode propertyName project + node.InnerText <- s + node + |> propertyGroup.AppendChild + |> ignore + propertyName,createRelativePath project.FileName fi.FullName,path.Substring(0,path.LastIndexOf("build\\") + 6)) |> Set.ofSeq propertyNames,propertyGroup @@ -753,7 +748,7 @@ module ProjectFile = // handle legacy conditions let conditions = - (model.GetReferenceFolders() @ netCoreRestricted.CompileRefFolders) + (model.GetReferenceFolders() @ (List.map (LibFolder.map (fun refs -> { ReferenceOrLibraryFolder.empty with Libraries = refs })) netCoreRestricted.CompileRefFolders)) |> List.sortBy (fun libFolder -> libFolder.Path) |> List.collect (fun libFolder -> match libFolder with @@ -766,34 +761,33 @@ module ProjectFile = | "$(TargetFrameworkIdentifier) == 'true'" -> "true" | _ -> condition - - let references = libFolder.Files.References |> Seq.sortBy (fun (r:Reference) -> r.Path) |> Seq.toList + let frameworkReferences = libFolder.FolderContents.FrameworkReferences |> Seq.sortBy (fun (r) -> r.Name) |> Seq.toList + let libraries = libFolder.FolderContents.Libraries |> Seq.sortBy (fun (r) -> r.Path) |> Seq.toList let assemblyTargets = ref libFolder.Targets let duplicates = HashSet<_>() - for lib in references do - match lib with - | Reference.FrameworkAssemblyReference frameworkAssembly -> - for t in libFolder.Targets do - if not <| usedFrameworkLibs.Add(t,frameworkAssembly) then - assemblyTargets := List.filter ((<>) t) !assemblyTargets - duplicates.Add lib |> ignore - | _ -> () + for frameworkAssembly in frameworkReferences do + for t in libFolder.Targets do + if not <| usedFrameworkLibs.Add(t,frameworkAssembly.Name) then + assemblyTargets := List.filter ((<>) t) !assemblyTargets + duplicates.Add frameworkAssembly.Name |> ignore if !assemblyTargets = libFolder.Targets then - [condition,createItemGroup libFolder.Targets references,false] + [condition,createItemGroup libFolder.Targets frameworkReferences libraries,false] else - let frameworkAssemblies,rest = - references - |> List.partition (fun lib -> - match lib with - | Reference.FrameworkAssemblyReference frameworkAssembly -> duplicates.Contains lib - | _ -> false) + let specialFrameworkAssemblies, rest = + frameworkReferences |> List.partition (fun fr -> duplicates.Contains fr.Name) + //let frameworkAssemblies,rest = + // references + // |> List.partition (fun lib -> + // match lib with + // | Reference.FrameworkAssemblyReference frameworkAssembly -> duplicates.Contains lib + // | _ -> false) match PlatformMatching.getCondition referenceCondition allTargets !assemblyTargets with - | "" -> [condition,createItemGroup libFolder.Targets rest,false] + | "" -> [condition,createItemGroup libFolder.Targets rest libraries,false] | lowerCondition -> - [lowerCondition,createItemGroup !assemblyTargets frameworkAssemblies,true - condition,createItemGroup libFolder.Targets rest,false] + [lowerCondition,createItemGroup !assemblyTargets specialFrameworkAssemblies [],true + condition,createItemGroup libFolder.Targets rest libraries,false] ) // global targets are targets, that are either directly in the /build folder. @@ -806,7 +800,7 @@ module ProjectFile = let frameworkSpecificTargetsFileConditions = frameworkSpecificTargets - |> List.map (fun lib -> PlatformMatching.getCondition referenceCondition allTargets lib.Targets,createPropertyGroup lib.Files.References) + |> List.map (fun lib -> PlatformMatching.getCondition referenceCondition allTargets lib.Targets,createPropertyGroup (lib.FolderContents |> List.ofSeq)) let chooseNodes = match conditions with @@ -915,7 +909,7 @@ module ProjectFile = let globalPropsNodes = globalTargets - |> Seq.collect (fun t -> t.Files.References) + |> Seq.collect (fun t -> t.FolderContents) |> Seq.map (fun t -> t.Path) |> Seq.distinct |> Seq.filter (fun t -> String.endsWithIgnoreCase ".props" t) @@ -929,7 +923,7 @@ module ProjectFile = let globalTargetsNodes = globalTargets - |> Seq.collect (fun t -> t.Files.References) + |> Seq.collect (fun t -> t.FolderContents) |> Seq.map (fun t -> t.Path) |> Seq.distinct |> Seq.filter (fun t -> String.endsWithIgnoreCase ".targets" t) @@ -1075,8 +1069,8 @@ module ProjectFile = if isTargetMatchingRestrictions(restrictionList,SinglePlatform targetFramework) then if projectModel.GetLibReferences targetFramework |> Seq.isEmpty then let libReferences = - projectModel.GetLibReferencesLazy |> force - |> Seq.filter (fun l -> match l with | Reference.Library _ -> true | _ -> false) + projectModel.GetAllLegacyReferences() // LibReferencesLazy |> force + //|> Seq.filter (fun l -> match l with | Reference.Library _ -> true | _ -> false) if not (Seq.isEmpty libReferences) then traceWarnfn "Package %O contains libraries, but not for the selected TargetFramework %O in project %s." diff --git a/src/Paket.Core/InstallModel.fs b/src/Paket.Core/InstallModel.fs index 3dd357c9f0..57fe4bb6cf 100644 --- a/src/Paket.Core/InstallModel.fs +++ b/src/Paket.Core/InstallModel.fs @@ -6,94 +6,59 @@ open Paket.Domain open Paket.Requirements open Logging open PlatformMatching +open ProviderImplementation.AssemblyReader.Utils.SHA1 type UnparsedPackageFile = Paket.NuGet.UnparsedPackageFile -[] -type Reference = - | Library of string - | TargetsFile of string - | FrameworkAssemblyReference of string - - member this.LibName = - match this with - | Reference.Library lib -> - let fi = FileInfo(normalizePath lib) - Some(fi.Name.Replace(fi.Extension, "")) - | _ -> None - - member this.FrameworkReferenceName = - match this with - | Reference.FrameworkAssemblyReference name -> Some name - | _ -> None +type Library = + { Name : string + Path : string } +module Library = + let ofFile (f:UnparsedPackageFile) = + let fi = FileInfo(normalizePath f.FullPath) + let name = fi.Name.Replace(fi.Extension, "") + { Name = name; Path = f.FullPath } + +type MsBuildFile = + { Name : string + Path : string } +module MsBuildFile = + let ofFile (f:UnparsedPackageFile) = + let fi = FileInfo(normalizePath f.FullPath) + let name = fi.Name.Replace(fi.Extension, "") + { Name = name; Path = f.FullPath } + +type FrameworkReference = + { Name : string } +module FrameworkReference = + let ofName n = { FrameworkReference.Name = n } + +type ReferenceOrLibraryFolder = + { FrameworkReferences : FrameworkReference Set + Libraries : Library Set } + +module ReferenceOrLibraryFolder = + let empty = { FrameworkReferences = Set.empty; Libraries = Set.empty } + let addLibrary item old = + { old with ReferenceOrLibraryFolder.Libraries = Set.add item old.Libraries } + let addFrameworkReference item old = + { old with ReferenceOrLibraryFolder.FrameworkReferences = Set.add item old.FrameworkReferences } - member this.ReferenceName = - match this with - | Reference.FrameworkAssemblyReference name -> name - | Reference.TargetsFile targetsFile -> - let fi = FileInfo(normalizePath targetsFile) - fi.Name.Replace(fi.Extension, "") - | Reference.Library lib -> - let fi = FileInfo(normalizePath lib) - fi.Name.Replace(fi.Extension, "") - - member this.Path = - match this with - | Reference.Library path -> path - | Reference.TargetsFile path -> path - | Reference.FrameworkAssemblyReference path -> path - -type InstallFiles = - { References : Reference Set - ContentFiles : string Set } - -[] -module InstallFiles = - let empty = - { References = Set.empty - ContentFiles = Set.empty } - - let addReference lib (installFiles:InstallFiles) = - { installFiles with References = Set.add (Reference.Library lib) installFiles.References } - - let singleton lib = empty |> addReference lib - - let addTargetsFile targetsFile (installFiles:InstallFiles) = - { installFiles with References = Set.add (Reference.TargetsFile targetsFile) installFiles.References } - - let addFrameworkAssemblyReference assemblyName (installFiles:InstallFiles) = - { installFiles with References = Set.add (Reference.FrameworkAssemblyReference assemblyName) installFiles.References } - - let getFrameworkAssemblies (installFiles:InstallFiles) = - installFiles.References - |> Set.map (fun r -> r.FrameworkReferenceName) - |> Seq.choose id - - let mergeWith (that:InstallFiles) (installFiles:InstallFiles) = - { installFiles with - References = Set.union that.References installFiles.References - ContentFiles = Set.union that.ContentFiles installFiles.ContentFiles } - -type InstallFiles with - member this.AddReference lib = InstallFiles.addReference lib this - member this.AddTargetsFile targetsFile = InstallFiles.addTargetsFile targetsFile this - member this.AddFrameworkAssemblyReference assemblyName = InstallFiles.addFrameworkAssemblyReference assemblyName this - member this.GetFrameworkAssemblies() = InstallFiles.getFrameworkAssemblies this - member this.MergeWith that = InstallFiles.mergeWith that this - -type RuntimeIdentifier = - { Rid: string } - static member Any = { Rid = "any" } /// Represents a subfolder of a nuget package that provides files (content, references, etc) for one or more Target Profiles. This is a logical representation of the 'net45' folder in a NuGet package, for example. -type LibFolder = +type LibFolder<'T> = { Path : ParsedPlatformPath Targets : TargetProfile list - Files : InstallFiles } + FolderContents : 'T } member this.GetSinglePlatforms() = this.Targets |> List.choose (function SinglePlatform t -> Some t | _ -> None) +module LibFolder = + let map f (l:LibFolder<_>) = + { Path = l.Path + Targets = l.Targets + FolderContents = f l.FolderContents } type AnalyzerLanguage = | Any | CSharp | FSharp | VisualBasic @@ -124,10 +89,10 @@ type AnalyzerLib = type InstallModel = { PackageName : PackageName PackageVersion : SemVerInfo - CompileLibFolders : LibFolder list - CompileRefFolders : LibFolder list - RuntimeLibFolders : LibFolder list - TargetsFileFolders : LibFolder list + CompileLibFolders : LibFolder list + CompileRefFolders : LibFolder list + RuntimeLibFolders : LibFolder list + TargetsFileFolders : LibFolder list Analyzers: AnalyzerLib list LicenseUrl: string option } @@ -339,7 +304,7 @@ module InstallModel = LicenseUrl = None } type Tfm = PlatformMatching.ParsedPlatformPath - type Rid = RuntimeIdentifier + type Rid = Paket.Rid let scanners = [ { FolderScanner.AdvancedScanner.Name = "noSeperator"; FolderScanner.AdvancedScanner.Parser = FolderScanner.check "seperator not allowed" (fun s -> not (s.Contains "/" || s.Contains "\\")) >> FolderScanner.ParseResult.box } @@ -353,21 +318,21 @@ module InstallModel = type FrameworkDependentFile = { Path : Tfm File : UnparsedPackageFile - Runtime : RuntimeIdentifier} + Runtime : Rid } let getCompileRefAssembly (p:UnparsedPackageFile) = (trySscanf "ref/%A{tfm}/%A{noSeperator}" p.PathWithinPackage : (Tfm * string) option) - |> Option.map (fun (l,_) -> { Path = l; File = p; Runtime = RuntimeIdentifier.Any }) + |> Option.map (fun (l,_) -> { Path = l; File = p; Runtime = Rid.Any }) let getRuntimeAssembly (p:UnparsedPackageFile) = (trySscanf "lib/%A{tfm}/%A{noSeperator}" p.PathWithinPackage : (Tfm * string) option) - |> Option.map (fun (l,_) -> { Path = l; File = p; Runtime = RuntimeIdentifier.Any }) + |> Option.map (fun (l,_) -> { Path = l; File = p; Runtime = Rid.Any }) |> Option.orElseWith (fun _ -> (trySscanf "runtimes/%A{rid}/lib/%A{tfm}/%A{noSeperator}" p.PathWithinPackage : (Rid * Tfm * string) option) |> Option.map (fun (rid, l, _) -> { Path = l; File = p; Runtime = rid })) |> Option.orElseWith (fun _ -> (trySscanf "lib/%A{noSeperator}" p.PathWithinPackage : string option) - |> Option.map (fun (_) -> { Path = Tfm.Empty; File = p; Runtime = RuntimeIdentifier.Any })) + |> Option.map (fun (_) -> { Path = Tfm.Empty; File = p; Runtime = Rid.Any })) let getCompileLibAssembly (p:UnparsedPackageFile) = // %s because 'native' uses subfolders... @@ -387,12 +352,12 @@ module InstallModel = if path.Contains "/release/" then Release else if path.Contains "/debug/" then Debug else NoBuildMode - { Path = { l with Platforms = [ FrameworkIdentifier.Native(newBuildMode,newPlatform) ]}; File = p; Runtime = RuntimeIdentifier.Any } + { Path = { l with Platforms = [ FrameworkIdentifier.Native(newBuildMode,newPlatform) ]}; File = p; Runtime = Rid.Any } else - { Path = l; File = p; Runtime = RuntimeIdentifier.Any }) + { Path = l; File = p; Runtime = Rid.Any }) |> Option.orElseWith (fun _ -> (trySscanf "lib/%A{noSeperator}" p.PathWithinPackage : string option) - |> Option.map (fun (_) -> { Path = Tfm.Empty; File = p; Runtime = RuntimeIdentifier.Any })) + |> Option.map (fun (_) -> { Path = Tfm.Empty; File = p; Runtime = Rid.Any })) let getRuntimeLibrary (p:UnparsedPackageFile) = (trySscanf "runtimes/%A{rid}/nativeassets/%A{tfm}/%A{noSeperator}" p.PathWithinPackage : (Rid * Tfm * string) option) @@ -403,30 +368,43 @@ module InstallModel = let getMsbuildFile (p:UnparsedPackageFile) = (trySscanf "build/%A{tfm}/%A{noSeperator}" p.PathWithinPackage : (Tfm * string) option) - |> Option.map (fun (l,_) -> { Path = l; File = p; Runtime = RuntimeIdentifier.Any }) + |> Option.map (fun (l,_) -> { Path = l; File = p; Runtime = Rid.Any }) |> Option.orElseWith (fun _ -> (trySscanf "build/%A{noSeperator}" p.PathWithinPackage : string option) - |> Option.map (fun (_) -> { Path = Tfm.Empty; File = p; Runtime = RuntimeIdentifier.Any })) - - let mapFolders mapfn (installModel:InstallModel) = - { installModel with - CompileLibFolders = List.map mapfn installModel.CompileLibFolders - CompileRefFolders = List.map mapfn installModel.CompileRefFolders - RuntimeLibFolders = List.map mapfn installModel.RuntimeLibFolders - TargetsFileFolders = List.map mapfn installModel.TargetsFileFolders } - - let mapFiles mapfn (installModel:InstallModel) = - installModel - |> mapFolders (fun folder -> { folder with Files = mapfn folder.Files }) + |> Option.map (fun (_) -> { Path = Tfm.Empty; File = p; Runtime = Rid.Any })) + + //let mapFolders mapfn (installModel:InstallModel) = + // { installModel with + // CompileLibFolders = List.map mapfn installModel.CompileLibFolders + // CompileRefFolders = List.map mapfn installModel.CompileRefFolders + // RuntimeLibFolders = List.map mapfn installModel.RuntimeLibFolders + // TargetsFileFolders = List.map mapfn installModel.TargetsFileFolders } + // + //let mapFiles mapfn (installModel:InstallModel) = + // installModel + // |> mapFolders (fun folder -> { folder with Files = mapfn folder.Files }) let private getFileFolders (target:TargetProfile) folderType choosefn = match Seq.tryFind (fun lib -> Seq.exists ((=) target) lib.Targets) folderType with - | Some folder -> folder.Files.References |> Seq.choose choosefn + | Some folder -> choosefn folder.FolderContents | None -> Seq.empty + let private getAllFiles folderType choosefn = + folderType + |> Seq.map (fun folder -> choosefn folder.FolderContents) + |> Seq.concat /// This is for library references, which at the same time can be used for references (old world - pre dotnetcore) let getLegacyReferences (target : TargetProfile) (installModel:InstallModel) = - getFileFolders target (installModel.CompileLibFolders) (function Reference.Library lib -> Some lib | _ -> None) + getFileFolders target (installModel.CompileLibFolders) (fun f -> f.Libraries |> Set.toSeq) + |> Seq.cache + let getLegacyFrameworkReferences (target : TargetProfile) (installModel:InstallModel) = + getFileFolders target (installModel.CompileLibFolders) (fun f -> f.FrameworkReferences |> Set.toSeq) + |> Seq.cache + let getAllLegacyFrameworkReferences (installModel:InstallModel) = + getAllFiles installModel.CompileLibFolders (fun f -> f.FrameworkReferences |> Set.toSeq) + |> Seq.cache + let getAllLegacyReferences (installModel:InstallModel) = + getAllFiles installModel.CompileLibFolders (fun f -> f.Libraries |> Set.toSeq) |> Seq.cache [] @@ -435,7 +413,7 @@ module InstallModel = /// This is for reference assemblies (new dotnetcore world) let getCompileReferences (target: TargetProfile) (installModel : InstallModel) = let results = - getFileFolders target (installModel.CompileRefFolders) (function Reference.Library lib -> Some lib | _ -> None) + getFileFolders target (installModel.CompileRefFolders) (fun f -> f |> Set.toSeq ) |> Seq.cache if results |> Seq.isEmpty then // Fallback for old packages @@ -443,88 +421,63 @@ module InstallModel = else results let getRuntimeLibraries graph rid (target : TargetProfile) (installModel:InstallModel) = - getFileFolders target (installModel.RuntimeLibFolders) (function Reference.Library lib -> Some lib | _ -> None) + getFileFolders target (installModel.RuntimeLibFolders) (fun f -> f |> Set.toSeq) |> Seq.cache let getTargetsFiles (target : TargetProfile) (installModel:InstallModel) = - getFileFolders target installModel.TargetsFileFolders - (function Reference.TargetsFile targetsFile -> Some targetsFile | _ -> None) + getFileFolders target installModel.TargetsFileFolders (fun f -> f |> Set.toSeq) /// This is for library references, which at the same time can be used for references (old world - pre dotnetcore) let getLegacyPlatformReferences frameworkIdentifier installModel = getLegacyReferences (SinglePlatform frameworkIdentifier) installModel - /// This is for framework references, those do not exist anymore (old world - pre dotnetcore) - let getLegacyFrameworkAssembliesLazy (installModel:InstallModel) = - lazy ([ for lib in installModel.CompileLibFolders do - yield! lib.Files.GetFrameworkAssemblies()] - |> Set.ofList) - - /// This is for library references, which at the same time can be used for references (old world - pre dotnetcore) - let getLegacyReferencesLazy installModel = - lazy ([ for lib in installModel.CompileLibFolders do - yield! lib.Files.References] - |> Set.ofList) - - /// This is for reference assemblies (new dotnetcore world) - let getReferencesLazy (installModel:InstallModel) = - lazy ([ for lib in installModel.CompileRefFolders do - yield! lib.Files.References] - |> Set.ofList) - /// This is for runtime assemblies (new dotnetcore world) - let getRuntimeAssembliesLazy (installModel:InstallModel) = - lazy ([ for lib in installModel.RuntimeLibFolders do - yield! lib.Files.References] - |> Set.ofList) - - let getTargetsFilesLazy (installModel:InstallModel) = - lazy ([ for lib in installModel.TargetsFileFolders do - yield! lib.Files.References] - |> Set.ofList) - + let isEmpty (lib: LibFolder> list) = + lib + |> Seq.map (fun l -> l.FolderContents) + |> Seq.forall Set.isEmpty let removeIfCompletelyEmpty (this:InstallModel) = - if Set.isEmpty (getLegacyFrameworkAssembliesLazy this |> force) - && Set.isEmpty (getLegacyReferencesLazy this |> force) - && Set.isEmpty (getReferencesLazy this |> force) - && Set.isEmpty (getRuntimeAssembliesLazy this |> force) - && Set.isEmpty (getTargetsFilesLazy this |> force) - && List.isEmpty this.Analyzers then + let foldersEmpty = + isEmpty this.CompileRefFolders && isEmpty this.TargetsFileFolders && isEmpty this.RuntimeLibFolders && + this.CompileLibFolders + |> Seq.map (fun c -> c.FolderContents.Libraries |> Set.toSeq, c.FolderContents.FrameworkReferences |> Set.toSeq) + |> Seq.forall (fun (libs, refs) -> Seq.isEmpty libs && Seq.isEmpty refs) + + if foldersEmpty && List.isEmpty this.Analyzers then emptyModel this.PackageName this.PackageVersion else this - let calcLibFoldersG (parsePackage : UnparsedPackageFile -> FrameworkDependentFile option) (libs:UnparsedPackageFile list) = + let calcLibFoldersG empty (parsePackage : UnparsedPackageFile -> FrameworkDependentFile option) (libs:UnparsedPackageFile list) = libs |> List.choose parsePackage |> List.map (fun p -> p.Path) |> List.distinct //By (fun f -> f.Platforms) |> List.sort |> PlatformMatching.getSupportedTargetProfiles - |> Seq.map (fun entry -> { Path = entry.Key; Targets = entry.Value; Files = InstallFiles.empty }) + |> Seq.map (fun entry -> { Path = entry.Key; Targets = entry.Value; FolderContents = empty }) |> Seq.toList - let calcLegacyReferenceLibFolders = calcLibFoldersG getCompileLibAssembly - let calcReferenceFolders = calcLibFoldersG getCompileRefAssembly - let calcRuntimeFolders = calcLibFoldersG getRuntimeAssembly + let calcLegacyReferenceLibFolders = calcLibFoldersG ReferenceOrLibraryFolder.empty getCompileLibAssembly + let calcReferenceFolders = calcLibFoldersG Set.empty getCompileRefAssembly + let calcRuntimeFolders = calcLibFoldersG Set.empty getRuntimeAssembly //let calcRefFolders = calcLibFoldersG extractRefFolder - let addFileToFolder (path:LibFolder) (file:UnparsedPackageFile) (folders:LibFolder list) (addfn: string -> InstallFiles -> InstallFiles) = + let addFileToFolder<'T, 'Item> (path:LibFolder<'T>) (file:'Item) (folders:LibFolder<'T> list) (addfn: 'Item -> 'T -> 'T) = folders |> List.map (fun p -> if p.Path <> path.Path then p else - { p with Files = addfn file.FullPath p.Files }) + { p with FolderContents = addfn file p.FolderContents }) - let private addPackageLegacyLibFile references (path:LibFolder) (file:UnparsedPackageFile) (this:InstallModel) : InstallModel = + let private addPackageLegacyLibFile references (path:LibFolder) (file:UnparsedPackageFile) (this:InstallModel) : InstallModel = let install = match references with | NuspecReferences.All -> true | NuspecReferences.Explicit list -> List.exists file.FullPath.EndsWith list - if not install then this else { this with - CompileLibFolders = addFileToFolder path file this.CompileLibFolders InstallFiles.addReference } + CompileLibFolders = addFileToFolder path (Library.ofFile file) this.CompileLibFolders ReferenceOrLibraryFolder.addLibrary } - let private addPackageRefFile references (path:LibFolder) (file:UnparsedPackageFile) (this:InstallModel) : InstallModel = + let private addPackageRefFile references (path:LibFolder) (file:UnparsedPackageFile) (this:InstallModel) : InstallModel = let install = match references with | NuspecReferences.All -> true @@ -532,9 +485,9 @@ module InstallModel = if not install then this else { this with - CompileRefFolders = addFileToFolder path file this.CompileRefFolders InstallFiles.addReference } + CompileRefFolders = addFileToFolder path (Library.ofFile file) this.CompileRefFolders Set.add } - let private addPackageRuntimeFile references (path:LibFolder) (file:UnparsedPackageFile) (this:InstallModel) : InstallModel = + let private addPackageRuntimeFile references (path:LibFolder) (file:UnparsedPackageFile) (this:InstallModel) : InstallModel = let install = match references with | NuspecReferences.All -> true @@ -542,13 +495,13 @@ module InstallModel = if not install then this else { this with - RuntimeLibFolders = addFileToFolder path file this.RuntimeLibFolders InstallFiles.addReference } + RuntimeLibFolders = addFileToFolder path (Library.ofFile file) this.RuntimeLibFolders Set.add } let private addItem libs extract addFunc getFolder initialState = List.fold (fun (model:InstallModel) file -> match extract file with | Some (folderName:FrameworkDependentFile) -> - match List.tryFind (fun (folder:LibFolder) -> folder.Path = folderName.Path) (getFolder model) with + match List.tryFind (fun (folder:LibFolder<_>) -> folder.Path = folderName.Path) (getFolder model) with | Some path -> addFunc path file model | _ -> model | None -> model) initialState libs @@ -576,13 +529,42 @@ module InstallModel = { installModel with Analyzers = installModel.Analyzers @ analyzerLibs} - let rec addTargetsFile (path:LibFolder) (file:UnparsedPackageFile) (installModel:InstallModel) :InstallModel = + let rec addTargetsFile (path:LibFolder<_>) (file:UnparsedPackageFile) (installModel:InstallModel) :InstallModel = { installModel with - TargetsFileFolders = addFileToFolder path file installModel.TargetsFileFolders InstallFiles.addTargetsFile + TargetsFileFolders = addFileToFolder path (MsBuildFile.ofFile file) installModel.TargetsFileFolders Set.add } + let mapFolderContents<'T> (mapfn: 'T -> 'T) folders = + folders + |> List.map (fun p -> + { p with FolderContents = mapfn p.FolderContents }) + + let mapCompileLibFolders mapfn (installModel:InstallModel) = + { installModel with + CompileLibFolders = List.map mapfn installModel.CompileLibFolders } + let mapCompileRefFolders mapfn (installModel:InstallModel) = + { installModel with + CompileRefFolders = List.map mapfn installModel.CompileRefFolders } + let mapRuntimeLibFolders mapfn (installModel:InstallModel) = + { installModel with + RuntimeLibFolders = List.map mapfn installModel.RuntimeLibFolders } + let mapTargetsFileFolders mapfn (installModel:InstallModel) = + { installModel with + TargetsFileFolders = List.map mapfn installModel.TargetsFileFolders } + + let mapCompileLibFrameworkReferences mapfn (installModel:InstallModel) = + mapCompileLibFolders (LibFolder.map (fun l -> { l with FrameworkReferences = mapfn l.FrameworkReferences })) installModel + let mapCompileLibReferences mapfn (installModel:InstallModel) = + mapCompileLibFolders (LibFolder.map (fun l -> { l with Libraries = mapfn l.Libraries })) installModel + let mapCompileRefFiles mapfn (installModel:InstallModel) = + mapCompileRefFolders (LibFolder.map (mapfn)) installModel + let mapRuntimeLibFiles mapfn (installModel:InstallModel) = + mapRuntimeLibFolders (LibFolder.map (mapfn)) installModel + let mapTargetsFiles mapfn (installModel:InstallModel) = + mapTargetsFileFolders (LibFolder.map (mapfn)) installModel + let addFrameworkAssemblyReference (installModel:InstallModel) (reference:FrameworkAssemblyReference) : InstallModel = - let referenceApplies (folder : LibFolder) = + let referenceApplies (folder : LibFolder<_>) = match reference.FrameworkRestrictions |> getRestrictionList with | [] -> true | restrictions -> @@ -613,48 +595,38 @@ module InstallModel = else installModel - model |> mapFolders(fun folder -> + model |> mapCompileLibFolders(fun folder -> if referenceApplies folder then - { folder with Files = folder.Files.AddFrameworkAssemblyReference reference.AssemblyName } + LibFolder.map (fun c -> { c with FrameworkReferences = Set.add (FrameworkReference.ofName reference.AssemblyName) c.FrameworkReferences }) folder + //{ folder with FolderContents = { folder.FolderContents with FrameworkReferences = Set.add reference.AssemblyName folder.FolderContents.FrameworkReferences } } else folder) let addFrameworkAssemblyReferences references (installModel:InstallModel) : InstallModel = references |> Seq.fold addFrameworkAssemblyReference (installModel:InstallModel) - let filterExcludes excludes (installModel:InstallModel) = - let excluded e reference = - match reference with - | Reference.Library x -> x.Contains e - | Reference.TargetsFile x -> x.Contains e - | Reference.FrameworkAssemblyReference x -> x.Contains e + + + let filterExcludes (excludes:string list) (installModel:InstallModel) = + let excluded e (reference:string) = + reference.Contains e excludes |> List.fold (fun (model:InstallModel) fileName -> - mapFiles (fun files -> { files with References = Set.filter (excluded fileName >> not) files.References }) model) - installModel + model + |> mapCompileLibReferences (Set.filter (fun n -> n.Name |> excluded fileName |> not)) + |> mapCompileLibFrameworkReferences (Set.filter (fun r -> r.Name |> excluded fileName |> not)) + ) installModel let filterBlackList (installModel:InstallModel) = - - let includeReferences = function - | Reference.Library lib -> not (String.endsWithIgnoreCase ".dll" lib || String.endsWithIgnoreCase ".exe" lib || String.endsWithIgnoreCase ".so" lib || String.endsWithIgnoreCase ".dylib" lib ) - | Reference.TargetsFile targetsFile -> - (not (String.endsWithIgnoreCase ".props" targetsFile|| String.endsWithIgnoreCase ".targets" targetsFile)) - | _ -> false - - let excludeSatelliteAssemblies = function - | Reference.Library lib -> lib.EndsWith ".resources.dll" - | _ -> false - - let blackList = - [ includeReferences - excludeSatelliteAssemblies] - - blackList - |> List.map (fun f -> f >> not) // inverse - |> List.fold (fun (model:InstallModel) f -> - mapFiles (fun files -> { files with References = Set.filter f files.References }) model) - installModel + installModel + |> mapCompileLibReferences (Set.filter (fun l -> + let lib = l.Path + (String.endsWithIgnoreCase ".dll" lib || String.endsWithIgnoreCase ".exe" lib || String.endsWithIgnoreCase ".so" lib || String.endsWithIgnoreCase ".dylib" lib ))) + |> mapCompileLibReferences (Set.filter (fun lib -> not (lib.Path.EndsWith ".resources.dll"))) + |> mapTargetsFiles (Set.filter (fun t -> + let targetsFile = t.Path + (String.endsWithIgnoreCase ".props" targetsFile|| String.endsWithIgnoreCase ".targets" targetsFile))) let applyFrameworkRestrictions (restrictions:FrameworkRestriction list) (installModel:InstallModel) = match restrictions with @@ -686,16 +658,20 @@ module InstallModel = let rec addTargetsFiles (targetsFiles:UnparsedPackageFile list) (this:InstallModel) : InstallModel = let targetsFileFolders = - calcLibFoldersG getMsbuildFile targetsFiles + calcLibFoldersG Set.empty getMsbuildFile targetsFiles { this with TargetsFileFolders = targetsFileFolders } |> addItem targetsFiles getMsbuildFile (addTargetsFile) (fun i -> i.TargetsFileFolders) - let filterReferences references (this:InstallModel) = - let inline mapfn (files:InstallFiles) = - { files with - References = files.References |> Set.filter (fun reference -> Set.contains reference.ReferenceName references |> not) - } - mapFiles mapfn this + + let filterReferences (references:string Set) (this:InstallModel) = + this + |> mapCompileLibReferences (Set.filter (fun reference -> Set.contains reference.Name references |> not)) + |> mapCompileLibFrameworkReferences (Set.filter (fun reference -> Set.contains reference.Name references |> not)) + //let inline mapfn (files:InstallFiles) = + // { files with + // References = files.References |> Set.filter (fun reference -> Set.contains reference.ReferenceName references |> not) + // } + //mapFiles mapfn this let addLicense url (model: InstallModel) = if String.IsNullOrWhiteSpace url then model @@ -719,9 +695,9 @@ type InstallModel with [] member this.GetReferenceFolders() = InstallModel.getCompileLibFolders this - member this.MapFolders mapfn = InstallModel.mapFolders mapfn this + //member this.MapFolders mapfn = InstallModel.mapFolders mapfn this - member this.MapFiles mapfn = InstallModel.mapFiles mapfn this + //member this.MapFiles mapfn = InstallModel.mapFiles mapfn this [] member this.GetLibReferences target = InstallModel.getLegacyReferences target this @@ -734,16 +710,22 @@ type InstallModel with member this.GetTargetsFiles target = InstallModel.getTargetsFiles target this - [] - member this.GetFrameworkAssembliesLazy = InstallModel.getLegacyFrameworkAssembliesLazy this - member this.GetLegacyFrameworkAssembliesLazy = InstallModel.getLegacyFrameworkAssembliesLazy this - - [] - member this.GetLibReferencesLazy = InstallModel.getLegacyReferencesLazy this - member this.GetLegacyReferencesLazy = InstallModel.getLegacyReferencesLazy this - member this.GetCompileReferencesLazy = InstallModel.getReferencesLazy this - - member this.GetTargetsFilesLazy = InstallModel.getTargetsFilesLazy this + member this.GetAllLegacyFrameworkReferences () = InstallModel.getAllLegacyFrameworkReferences this + member this.GetAllLegacyReferences () = InstallModel.getAllLegacyReferences this + member this.GetAllLegacyReferenceAndFrameworkReferenceNames () = + this.GetAllLegacyFrameworkReferences() |> Seq.map (fun r -> r.Name) + |> Seq.append (this.GetAllLegacyReferences() |> Seq.map (fun r -> r.Name)) + |> Set.ofSeq + //[] + //member this.GetFrameworkAssembliesLazy = InstallModel.getLegacyFrameworkAssembliesLazy this + //member this.GetLegacyFrameworkAssembliesLazy = InstallModel.getLegacyFrameworkAssembliesLazy this + + //[] + //member this.GetLibReferencesLazy = InstallModel.getLegacyReferencesLazy this + //member this.GetLegacyReferencesLazy = InstallModel.getLegacyReferencesLazy this + //member this.GetCompileReferencesLazy = InstallModel.getReferencesLazy this + // + //member this.GetTargetsFilesLazy = InstallModel.getTargetsFilesLazy this [] member this.CalcLibFolders libs = InstallModel.calcLegacyReferenceLibFolders libs diff --git a/src/Paket.Core/InstallProcess.fs b/src/Paket.Core/InstallProcess.fs index 348ca5475f..be52d5b752 100644 --- a/src/Paket.Core/InstallProcess.fs +++ b/src/Paket.Core/InstallProcess.fs @@ -199,7 +199,7 @@ let brokenDeps = HashSet<_>() /// Applies binding redirects for all strong-named references to all app. and web.config files. let private applyBindingRedirects isFirstGroup createNewBindingFiles redirects cleanBindingRedirects - root groupName findDependencies allKnownLibs + root groupName findDependencies allKnownLibNames (projectCache: Dictionary) extractedPackages = @@ -263,12 +263,12 @@ let private applyBindingRedirects isFirstGroup createNewBindingFiles redirects c |> Seq.collect (fun (_,profile) -> model.GetLibReferences profile |> Seq.map (fun x -> x, redirects, profile))) - |> Seq.groupBy (fun (p,_,profile) -> profile,FileInfo(p).Name) + |> Seq.groupBy (fun (p,_,profile) -> profile,FileInfo(p.Path).Name) |> Seq.choose(fun (_,librariesForPackage) -> librariesForPackage |> Seq.choose(fun (library,redirects,profile) -> try - let assembly = Mono.Cecil.AssemblyDefinition.ReadAssembly(library) + let assembly = Mono.Cecil.AssemblyDefinition.ReadAssembly(library.Path) Some (assembly, BindingRedirects.getPublicKeyToken assembly, assembly.MainModule.AssemblyReferences, redirects, profile) with _ -> None) |> Seq.sortBy(fun (assembly,_,_,_,_) -> assembly.Name.Version) @@ -303,7 +303,7 @@ let private applyBindingRedirects isFirstGroup createNewBindingFiles redirects c Culture = None }) |> Seq.sort - applyBindingRedirectsToFolder isFirstGroup createNewBindingFiles cleanBindingRedirects root allKnownLibs bindingRedirects + applyBindingRedirectsToFolder isFirstGroup createNewBindingFiles cleanBindingRedirects root allKnownLibNames bindingRedirects let installForDotnetSDK root (project:ProjectFile) = let paketTargetsPath = RestoreProcess.extractBuildTask(root) @@ -494,9 +494,9 @@ let InstallIntoProjects(options : InstallerOptions, forceTouch, dependenciesFile | true -> Some true | false -> None - let allKnownLibs = + let allKnownLibNames = model - |> Seq.map (fun kv -> (snd kv.Value).GetLibReferencesLazy.Force()) + |> Seq.map (fun kv -> (snd kv.Value).GetAllLegacyReferenceAndFrameworkReferenceNames()) |> Set.unionMany for g in lockFile.Groups do @@ -518,7 +518,7 @@ let InstallIntoProjects(options : InstallerOptions, forceTouch, dependenciesFile (FileInfo project.FileName).Directory.FullName g.Key lockFile.GetAllDependenciesOf - allKnownLibs + allKnownLibNames projectCache first := false diff --git a/src/Paket.Core/RuntimeGraph.fs b/src/Paket.Core/RuntimeGraph.fs index 227adc26b1..084f83f100 100644 --- a/src/Paket.Core/RuntimeGraph.fs +++ b/src/Paket.Core/RuntimeGraph.fs @@ -13,6 +13,7 @@ type Rid = static member Of s = { Rid = s } static member Parse s = Rid.Of s override x.ToString () = x.Rid + static member Any = { Rid = "any" } type CompatibilityProfileName = string diff --git a/src/Paket.Core/ScriptGeneration.fs b/src/Paket.Core/ScriptGeneration.fs index 696a1215c2..085f59f6ee 100644 --- a/src/Paket.Core/ScriptGeneration.fs +++ b/src/Paket.Core/ScriptGeneration.fs @@ -58,6 +58,7 @@ module PackageAndAssemblyResolution = let dllFiles = installModel |> InstallModel.getLegacyReferences (SinglePlatform framework) + |> Seq.map (fun l -> l.Path) |> Seq.map (fun path -> AssemblyDefinition.ReadAssembly path, FileInfo(path)) |> dict @@ -77,9 +78,8 @@ module PackageAndAssemblyResolution = then List.empty else installModel - |> InstallModel.getLegacyFrameworkAssembliesLazy - |> force - |> Set.toList + |> InstallModel.getAllLegacyFrameworkReferences + |> Seq.toList module ScriptGeneration = open PackageAndAssemblyResolution @@ -258,9 +258,9 @@ module ScriptGeneration = mainGroupSeen := true let model = Queries.getInstalledPackageModel lockFile (QualifiedPackageName.FromStrings(Some group, nuget)) - let libs = model.GetLibReferences(framework) |> Seq.map (fun f -> FileInfo f) - let syslibs = model.GetFrameworkAssembliesLazy.Value - yield group, (libs, syslibs |> Set.toSeq) + let libs = model.GetLibReferences(framework) |> Seq.map (fun f -> FileInfo f.Path) + let syslibs = model.GetAllLegacyFrameworkReferences() + yield group, (libs, syslibs) if not !mainGroupSeen && groups = [] then yield mainGroupKey, (Seq.empty, Seq.empty) // Always generate Main group @@ -271,7 +271,7 @@ module ScriptGeneration = for group, libs in all do let assemblies, frameworkLibs = Seq.foldBack (fun (l,r) (pl, pr) -> Seq.concat [pl ; l], Seq.concat [pr ; r]) libs (Seq.empty, Seq.empty) - |> fun (l,r) -> Seq.distinct l, Seq.distinct r |> filterFrameworkAssemblies + |> fun (l,r) -> Seq.distinct l, Seq.distinct r |> Seq.map (fun ref -> ref.Name) |> filterFrameworkAssemblies let assemblies = let assemblyFilePerAssemblyDef = @@ -323,7 +323,7 @@ module ScriptGeneration = PackageName = installModel.PackageName PackagesOrGroupFolder = packagesOrGroupFolder IncludeScriptsRootFolder = includeScriptsRootFolder - FrameworkReferences = getFrameworkReferencesWithinPackage framework installModel + FrameworkReferences = getFrameworkReferencesWithinPackage framework installModel |> List.map (fun ref -> ref.Name) OrderedDllReferences = dllFiles DependentScripts = dependencies } diff --git a/tests/Paket.Tests/InstallModel/ProcessingSpecs.fs b/tests/Paket.Tests/InstallModel/ProcessingSpecs.fs index f177750a2a..705774e82e 100644 --- a/tests/Paket.Tests/InstallModel/ProcessingSpecs.fs +++ b/tests/Paket.Tests/InstallModel/ProcessingSpecs.fs @@ -32,14 +32,17 @@ let ``should create empty model with net40, net45 ...``() = let ``should understand net40 and net45``() = let model = emptymodel.AddReferences ([ @"..\Rx-Main\lib\net40\Rx.dll"; @"..\Rx-Main\lib\net45\Rx.dll" ] |> fromLegacyList @"..\Rx-Main\") - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_Client)) |> shouldContain @"..\Rx-Main\lib\net40\Rx.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) |> shouldContain @"..\Rx-Main\lib\net45\Rx.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_Client)) + |> Seq.map (fun f -> f.Path) |> shouldContain (@"..\Rx-Main\lib\net40\Rx.dll") + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) + |> Seq.map (fun f -> f.Path)|> shouldContain @"..\Rx-Main\lib\net45\Rx.dll" [] let ``should understand lib in lib.dll``() = let model = emptymodel.AddReferences ([ @"..\FunScript.TypeScript\lib\net40\FunScript.TypeScript.Binding.lib.dll" ] |> fromLegacyList @"..\FunScript.TypeScript\") - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_Client)) |> shouldContain @"..\FunScript.TypeScript\lib\net40\FunScript.TypeScript.Binding.lib.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_Client)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\FunScript.TypeScript\lib\net40\FunScript.TypeScript.Binding.lib.dll" //[] //let ``should understand libuv in runtimes``() = @@ -56,32 +59,44 @@ let ``should understand reference folder``() = @"..\System.Security.Cryptography.Algorithms\lib\net35\System.Security.Cryptography.Algorithms.dll" ] |> fromLegacyList @"..\System.Security.Cryptography.Algorithms\") - let refs = model.GetLegacyReferences(SinglePlatform (DotNetStandard DotNetStandardVersion.V1_6)) + let refs = + model.GetLegacyReferences(SinglePlatform (DotNetStandard DotNetStandardVersion.V1_6)) + |> Seq.map (fun f -> f.Path) refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\runtimes\win\lib\net46\System.Security.Cryptography.Algorithms.dll" refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\lib\net35\System.Security.Cryptography.Algorithms.dll" refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\ref\netstandard1.6\System.Security.Cryptography.Algorithms.dll" - let refs = model.GetLegacyReferences(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) + let refs = + model.GetLegacyReferences(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) + |> Seq.map (fun f -> f.Path) refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\runtimes\win\lib\net46\System.Security.Cryptography.Algorithms.dll" refs |> shouldContain @"..\System.Security.Cryptography.Algorithms\lib\net35\System.Security.Cryptography.Algorithms.dll" refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\ref\netstandard1.6\System.Security.Cryptography.Algorithms.dll" - let refs = model.GetLegacyReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) + let refs = + model.GetLegacyReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) + |> Seq.map (fun f -> f.Path) refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\runtimes\win\lib\net46\System.Security.Cryptography.Algorithms.dll" refs |> shouldContain @"..\System.Security.Cryptography.Algorithms\lib\net35\System.Security.Cryptography.Algorithms.dll" refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\ref\netstandard1.6\System.Security.Cryptography.Algorithms.dll" - let refs = model.GetCompileReferences(SinglePlatform (DotNetStandard DotNetStandardVersion.V1_6)) + let refs = + model.GetCompileReferences(SinglePlatform (DotNetStandard DotNetStandardVersion.V1_6)) + |> Seq.map (fun f -> f.Path) refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\runtimes\win\lib\net46\System.Security.Cryptography.Algorithms.dll" refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\lib\net35\System.Security.Cryptography.Algorithms.dll" refs |> shouldContain @"..\System.Security.Cryptography.Algorithms\ref\netstandard1.6\System.Security.Cryptography.Algorithms.dll" - let refs = model.GetCompileReferences(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) + let refs = + model.GetCompileReferences(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) + |> Seq.map (fun f -> f.Path) refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\runtimes\win\lib\net46\System.Security.Cryptography.Algorithms.dll" refs |> shouldContain @"..\System.Security.Cryptography.Algorithms\lib\net35\System.Security.Cryptography.Algorithms.dll" refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\ref\netstandard1.6\System.Security.Cryptography.Algorithms.dll" - let refs = model.GetCompileReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) + let refs = + model.GetCompileReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) + |> Seq.map (fun f -> f.Path) refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\runtimes\win\lib\net46\System.Security.Cryptography.Algorithms.dll" refs |> shouldContain @"..\System.Security.Cryptography.Algorithms\lib\net35\System.Security.Cryptography.Algorithms.dll" refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\ref\netstandard1.6\System.Security.Cryptography.Algorithms.dll" @@ -92,32 +107,44 @@ let ``should understand reference folder``() = @"..\System.Security.Cryptography.Algorithms\ref\netstandard1.6\System.Security.Cryptography.Algorithms.dll" @"..\System.Security.Cryptography.Algorithms\lib\netstandard1.6\System.Security.Cryptography.Algorithms.dll" ] |> fromLegacyList @"..\System.Security.Cryptography.Algorithms\") - let refs = model.GetLegacyReferences(SinglePlatform (DotNetStandard DotNetStandardVersion.V1_6)) + let refs = + model.GetLegacyReferences(SinglePlatform (DotNetStandard DotNetStandardVersion.V1_6)) + |> Seq.map (fun f -> f.Path) refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\runtimes\win\lib\net46\System.Security.Cryptography.Algorithms.dll" refs |> shouldContain @"..\System.Security.Cryptography.Algorithms\lib\netstandard1.6\System.Security.Cryptography.Algorithms.dll" refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\ref\netstandard1.6\System.Security.Cryptography.Algorithms.dll" - let refs = model.GetLegacyReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_6_3)) + let refs = + model.GetLegacyReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_6_3)) + |> Seq.map (fun f -> f.Path) refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\runtimes\win\lib\net46\System.Security.Cryptography.Algorithms.dll" refs |> shouldContain @"..\System.Security.Cryptography.Algorithms\lib\netstandard1.6\System.Security.Cryptography.Algorithms.dll" refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\ref\netstandard1.6\System.Security.Cryptography.Algorithms.dll" - let refs = model.GetCompileReferences(SinglePlatform (DotNetStandard DotNetStandardVersion.V1_6)) + let refs = + model.GetCompileReferences(SinglePlatform (DotNetStandard DotNetStandardVersion.V1_6)) + |> Seq.map (fun f -> f.Path) refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\runtimes\win\lib\net46\System.Security.Cryptography.Algorithms.dll" refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\lib\netstandard1.6\System.Security.Cryptography.Algorithms.dll" refs |> shouldContain @"..\System.Security.Cryptography.Algorithms\ref\netstandard1.6\System.Security.Cryptography.Algorithms.dll" - let refs = model.GetCompileReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_6_3)) + let refs = + model.GetCompileReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_6_3)) + |> Seq.map (fun f -> f.Path) refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\runtimes\win\lib\net46\System.Security.Cryptography.Algorithms.dll" refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\lib\netstandard1.6\System.Security.Cryptography.Algorithms.dll" refs |> shouldContain @"..\System.Security.Cryptography.Algorithms\ref\netstandard1.6\System.Security.Cryptography.Algorithms.dll" - let refs = model.GetRuntimeLibraries null null (SinglePlatform (DotNetStandard DotNetStandardVersion.V1_6)) + let refs = + model.GetRuntimeLibraries null null (SinglePlatform (DotNetStandard DotNetStandardVersion.V1_6)) + |> Seq.map (fun f -> f.Path) refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\runtimes\win\lib\net46\System.Security.Cryptography.Algorithms.dll" refs |> shouldContain @"..\System.Security.Cryptography.Algorithms\lib\netstandard1.6\System.Security.Cryptography.Algorithms.dll" refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\ref\netstandard1.6\System.Security.Cryptography.Algorithms.dll" - let refs = model.GetRuntimeLibraries null null(SinglePlatform (DotNetFramework FrameworkVersion.V4_6_3)) + let refs = + model.GetRuntimeLibraries null null(SinglePlatform (DotNetFramework FrameworkVersion.V4_6_3)) + |> Seq.map (fun f -> f.Path) refs |> shouldContain @"..\System.Security.Cryptography.Algorithms\runtimes\win\lib\net46\System.Security.Cryptography.Algorithms.dll" // TODO: This is kind of broken for now -> the correct results depends on the runtime we want to get the runtime libraries for // therefore GetRuntimeLibraries needs an additional parameter... @@ -135,37 +162,51 @@ let ``should understand reference folder``() = let ``should understand mylib in mylib.dll``() = let model = emptymodel.AddReferences ([ @"c:/users/username/workspace/myproject/packages/mylib.mylib/lib/net45/mylib.mylib.dll" ] |> fromLegacyList @"c:/users/username/workspace/myproject/packages/mylib.mylib/") - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) |> shouldContain @"c:/users/username/workspace/myproject/packages/mylib.mylib/lib/net45/mylib.mylib.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"c:/users/username/workspace/myproject/packages/mylib.mylib/lib/net45/mylib.mylib.dll" [] let ``should add net35 if we have net20 and net40``() = let model = emptymodel.AddReferences([ @"..\Rx-Main\lib\net20\Rx.dll"; @"..\Rx-Main\lib\net40\Rx.dll" ] |> fromLegacyList @"..\Rx-Main\") - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V2)) |> shouldContain @"..\Rx-Main\lib\net20\Rx.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) |> shouldContain @"..\Rx-Main\lib\net20\Rx.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) |> shouldContain @"..\Rx-Main\lib\net40\Rx.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) |> shouldNotContain @"..\Rx-Main\lib\net20\Rx.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) |> shouldContain @"..\Rx-Main\lib\net40\Rx.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5_1)) |> shouldContain @"..\Rx-Main\lib\net40\Rx.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V2)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Rx-Main\lib\net20\Rx.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Rx-Main\lib\net20\Rx.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Rx-Main\lib\net40\Rx.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) + |> Seq.map (fun f -> f.Path) |> shouldNotContain @"..\Rx-Main\lib\net20\Rx.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Rx-Main\lib\net40\Rx.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5_1)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Rx-Main\lib\net40\Rx.dll" [] let ``should put _._ files into right buckets``() = let model = emptymodel.AddReferences ([ @"..\Rx-Main\lib\net40\_._"; @"..\Rx-Main\lib\net20\_._" ] |> fromLegacyList @"..\Rx-Main\") - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V2)) |> shouldContain @"..\Rx-Main\lib\net20\_._" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_Client)) |> shouldContain @"..\Rx-Main\lib\net40\_._" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V2)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Rx-Main\lib\net20\_._" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_Client)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Rx-Main\lib\net40\_._" [] let ``should inherit _._ files to higher frameworks``() = let model = emptymodel.AddReferences([ @"..\Rx-Main\lib\net40\_._"; @"..\Rx-Main\lib\net20\_._" ] |> fromLegacyList @"..\Rx-Main\") - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V2)) |> shouldContain @"..\Rx-Main\lib\net20\_._" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) |> shouldContain @"..\Rx-Main\lib\net20\_._" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) |> shouldContain @"..\Rx-Main\lib\net40\_._" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) |> shouldContain @"..\Rx-Main\lib\net40\_._" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5_1)) |> shouldContain @"..\Rx-Main\lib\net40\_._" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V2)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Rx-Main\lib\net20\_._" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Rx-Main\lib\net20\_._" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Rx-Main\lib\net40\_._" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Rx-Main\lib\net40\_._" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5_1)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Rx-Main\lib\net40\_._" [] @@ -173,10 +214,14 @@ let ``should skip buckets which contain placeholder while adjusting upper versio let model = emptymodel.AddReferences([ @"..\Rx-Main\lib\net20\Rx.dll"; @"..\Rx-Main\lib\net40\_._" ] |> fromLegacyList @"..\Rx-Main\") - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V2)) |> shouldContain @"..\Rx-Main\lib\net20\Rx.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) |> shouldContain @"..\Rx-Main\lib\net20\Rx.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) |> shouldNotContain @"..\Rx-Main\lib\net20\Rx.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) |> shouldNotContain @"..\Rx-Main\lib\net20\Rx.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V2)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Rx-Main\lib\net20\Rx.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Rx-Main\lib\net20\Rx.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) + |> Seq.map (fun f -> f.Path) |> shouldNotContain @"..\Rx-Main\lib\net20\Rx.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) + |> Seq.map (fun f -> f.Path) |> shouldNotContain @"..\Rx-Main\lib\net20\Rx.dll" [] let ``should filter _._ when processing blacklist``() = @@ -184,17 +229,22 @@ let ``should filter _._ when processing blacklist``() = emptymodel.AddReferences([ @"..\Rx-Main\lib\net40\_._"; @"..\Rx-Main\lib\net20\_._" ] |> fromLegacyList @"..\Rx-Main\") .FilterBlackList() - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V2)) |> shouldNotContain @"..\Rx-Main\lib\net20\_._" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) |> shouldNotContain @"..\Rx-Main\lib\net40\_._" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V2)) + |> Seq.map (fun f -> f.Path) |> shouldNotContain @"..\Rx-Main\lib\net20\_._" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) + |> Seq.map (fun f -> f.Path) |> shouldNotContain @"..\Rx-Main\lib\net40\_._" [] let ``should install single client profile lib for everything``() = let model = emptymodel.AddReferences([ @"..\Castle.Core\lib\net40-client\Castle.Core.dll" ] |> fromLegacyList @"..\Castle.Core\") - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_Client)) |> shouldContain @"..\Castle.Core\lib\net40-client\Castle.Core.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) |> shouldContain @"..\Castle.Core\lib\net40-client\Castle.Core.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) |> shouldContain @"..\Castle.Core\lib\net40-client\Castle.Core.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_Client)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Castle.Core\lib\net40-client\Castle.Core.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Castle.Core\lib\net40-client\Castle.Core.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Castle.Core\lib\net40-client\Castle.Core.dll" [] @@ -204,9 +254,12 @@ let ``should install net40 for client profile``() = [ @"..\Newtonsoft.Json\lib\net35\Newtonsoft.Json.dll" @"..\Newtonsoft.Json\lib\net40\Newtonsoft.Json.dll"] |> fromLegacyList @"..\Newtonsoft.Json\") - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) |> shouldContain @"..\Newtonsoft.Json\lib\net35\Newtonsoft.Json.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_Client)) |> shouldContain @"..\Newtonsoft.Json\lib\net40\Newtonsoft.Json.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) |> shouldContain @"..\Newtonsoft.Json\lib\net40\Newtonsoft.Json.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Newtonsoft.Json\lib\net35\Newtonsoft.Json.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_Client)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Newtonsoft.Json\lib\net40\Newtonsoft.Json.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Newtonsoft.Json\lib\net40\Newtonsoft.Json.dll" [] let ``should install not use net40-full for client profile``() = @@ -215,9 +268,12 @@ let ``should install not use net40-full for client profile``() = [ @"..\Newtonsoft.Json\lib\net35\Newtonsoft.Json.dll" @"..\Newtonsoft.Json\lib\net40-full\Newtonsoft.Json.dll"] |> fromLegacyList @"..\Newtonsoft.Json\") - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) |> shouldContain @"..\Newtonsoft.Json\lib\net35\Newtonsoft.Json.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) |> shouldContain @"..\Newtonsoft.Json\lib\net40-full\Newtonsoft.Json.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_Client)) |> shouldNotContain @"..\Newtonsoft.Json\lib\net40-full\Newtonsoft.Json.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Newtonsoft.Json\lib\net35\Newtonsoft.Json.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Newtonsoft.Json\lib\net40-full\Newtonsoft.Json.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_Client)) + |> Seq.map (fun f -> f.Path) |> shouldNotContain @"..\Newtonsoft.Json\lib\net40-full\Newtonsoft.Json.dll" [] let ``should handle lib install of Microsoft.Net.Http for .NET 4.5``() = @@ -231,33 +287,44 @@ let ``should handle lib install of Microsoft.Net.Http for .NET 4.5``() = @"..\Microsoft.Net.Http\lib\net45\System.Net.Http.Extensions.dll" @"..\Microsoft.Net.Http\lib\net45\System.Net.Http.Primitives.dll" ] |> fromLegacyList @"..\Microsoft.Net.Http\") - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) |> shouldNotContain @"..\Microsoft.Net.Http\lib\net40\System.Net.Http.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) + |> Seq.map (fun f -> f.Path) |> shouldNotContain @"..\Microsoft.Net.Http\lib\net40\System.Net.Http.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) |> shouldContain @"..\Microsoft.Net.Http\lib\net40\System.Net.Http.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) |> shouldContain @"..\Microsoft.Net.Http\lib\net40\System.Net.Http.Primitives.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) |> shouldContain @"..\Microsoft.Net.Http\lib\net40\System.Net.Http.WebRequest.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Net.Http\lib\net40\System.Net.Http.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Net.Http\lib\net40\System.Net.Http.Primitives.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Net.Http\lib\net40\System.Net.Http.WebRequest.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) |> shouldNotContain @"..\Microsoft.Net.Http\lib\net40\System.Net.Http.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) |> shouldContain @"..\Microsoft.Net.Http\lib\net45\System.Net.Http.Primitives.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) + |> Seq.map (fun f -> f.Path) |> shouldNotContain @"..\Microsoft.Net.Http\lib\net40\System.Net.Http.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Net.Http\lib\net45\System.Net.Http.Primitives.dll" [] let ``should add portable lib``() = let model = emptymodel.AddReferences([ @"..\Jint\lib\portable-net40+sl50+win+wp80\Jint.dll" ] |> fromLegacyList @"..\Jint\") - model.GetLibReferences(KnownTargetProfiles.FindPortableProfile "Profile147") |> shouldContain @"..\Jint\lib\portable-net40+sl50+win+wp80\Jint.dll" + model.GetLibReferences(KnownTargetProfiles.FindPortableProfile "Profile147") + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Jint\lib\portable-net40+sl50+win+wp80\Jint.dll" [] let ``should handle lib install of Jint for NET >= 40 and SL >= 50``() = let model = emptymodel.AddReferences([ @"..\Jint\lib\portable-net40+sl50+win+wp80\Jint.dll" ] |> fromLegacyList @"..\Jint\") - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) |> shouldContain @"..\Jint\lib\portable-net40+sl50+win+wp80\Jint.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Jint\lib\portable-net40+sl50+win+wp80\Jint.dll" - model.GetLibReferences(SinglePlatform (Silverlight "v5.0")) |> shouldContain @"..\Jint\lib\portable-net40+sl50+win+wp80\Jint.dll" + model.GetLibReferences(SinglePlatform (Silverlight "v5.0")) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Jint\lib\portable-net40+sl50+win+wp80\Jint.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) |> shouldNotContain @"..\Jint\lib\portable-net40+sl50+win+wp80\Jint.dll" - model.GetLibReferences(KnownTargetProfiles.FindPortableProfile "Profile147") |> shouldContain @"..\Jint\lib\portable-net40+sl50+win+wp80\Jint.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) + |> Seq.map (fun f -> f.Path) |> shouldNotContain @"..\Jint\lib\portable-net40+sl50+win+wp80\Jint.dll" + model.GetLibReferences(KnownTargetProfiles.FindPortableProfile "Profile147") + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Jint\lib\portable-net40+sl50+win+wp80\Jint.dll" [] let ``should handle lib install of Microsoft.BCL for NET >= 40``() = @@ -270,11 +337,15 @@ let ``should handle lib install of Microsoft.BCL for NET >= 40``() = @"..\Microsoft.Bcl\lib\net45\_._" ] |> fromLegacyList @"..\Microsoft.Bcl\") .FilterBlackList() - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) |> shouldNotContain @"..\Microsoft.Bcl\lib\net40\System.IO.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) + |> Seq.map (fun f -> f.Path) |> shouldNotContain @"..\Microsoft.Bcl\lib\net40\System.IO.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) |> shouldContain @"..\Microsoft.Bcl\lib\net40\System.IO.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) |> shouldContain @"..\Microsoft.Bcl\lib\net40\System.Runtime.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) |> shouldContain @"..\Microsoft.Bcl\lib\net40\System.Threading.Tasks.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Bcl\lib\net40\System.IO.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Bcl\lib\net40\System.Runtime.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Bcl\lib\net40\System.Threading.Tasks.dll" model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) |> shouldBeEmpty model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5_1)) |> shouldBeEmpty @@ -307,31 +378,44 @@ let ``should not use portable-net40 if we have net40``() = @"..\Microsoft.Bcl\lib\portable-net40+sl4+win8\System.Runtime.dll" @"..\Microsoft.Bcl\lib\portable-net40+sl4+win8\System.Threading.Tasks.dll" ] |> fromLegacyList @"..\Microsoft.Bcl\") - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_Client)) |> shouldContain @"..\Microsoft.Bcl\lib\net40\System.IO.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_Client)) |> shouldContain @"..\Microsoft.Bcl\lib\net40\System.Runtime.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_Client)) |> shouldContain @"..\Microsoft.Bcl\lib\net40\System.Threading.Tasks.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_Client)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Bcl\lib\net40\System.IO.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_Client)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Bcl\lib\net40\System.Runtime.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_Client)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Bcl\lib\net40\System.Threading.Tasks.dll" let profile41 = KnownTargetProfiles.FindPortableProfile "Profile41" - model.GetLibReferences(profile41) |> shouldContain @"..\Microsoft.Bcl\lib\portable-net40+sl4+win8\System.IO.dll" - model.GetLibReferences(profile41) |> shouldContain @"..\Microsoft.Bcl\lib\portable-net40+sl4+win8\System.Runtime.dll" - model.GetLibReferences(profile41) |> shouldContain @"..\Microsoft.Bcl\lib\portable-net40+sl4+win8\System.Threading.Tasks.dll" + model.GetLibReferences(profile41) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Bcl\lib\portable-net40+sl4+win8\System.IO.dll" + model.GetLibReferences(profile41) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Bcl\lib\portable-net40+sl4+win8\System.Runtime.dll" + model.GetLibReferences(profile41) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Bcl\lib\portable-net40+sl4+win8\System.Threading.Tasks.dll" [] let ``should handle lib install of DotNetZip 1.9.3``() = let model = emptymodel.AddReferences([ @"..\DotNetZip\lib\net20\Ionic.Zip.dll" ] |> fromLegacyList @"..\DotNetZip\") - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V2)) |> shouldContain @"..\DotNetZip\lib\net20\Ionic.Zip.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) |> shouldContain @"..\DotNetZip\lib\net20\Ionic.Zip.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) |> shouldContain @"..\DotNetZip\lib\net20\Ionic.Zip.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) |> shouldContain @"..\DotNetZip\lib\net20\Ionic.Zip.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V2)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\DotNetZip\lib\net20\Ionic.Zip.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\DotNetZip\lib\net20\Ionic.Zip.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\DotNetZip\lib\net20\Ionic.Zip.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\DotNetZip\lib\net20\Ionic.Zip.dll" [] let ``should handle lib install of NUnit 2.6 for windows 8``() = let model = emptymodel.AddReferences([ @"..\NUnit\lib\nunit.framework.dll" ] |> fromLegacyList @"..\NUnit\") - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V2)) |> shouldContain @"..\NUnit\lib\nunit.framework.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) |> shouldContain @"..\NUnit\lib\nunit.framework.dll" - model.GetLibReferences(SinglePlatform (Windows "v4.5")) |> shouldContain @"..\NUnit\lib\nunit.framework.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V2)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\NUnit\lib\nunit.framework.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\NUnit\lib\nunit.framework.dll" + model.GetLibReferences(SinglePlatform (Windows "v4.5")) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\NUnit\lib\nunit.framework.dll" [] @@ -365,38 +449,59 @@ let ``should handle lib install of Microsoft.Net.Http 2.2.28``() = @"..\Microsoft.Net.Http\lib\wpa81\System.Net.Http.Extensions.dll" @"..\Microsoft.Net.Http\lib\wpa81\System.Net.Http.Primitives.dll" ] |> fromLegacyList @"..\Microsoft.Net.Http\") - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) |> shouldNotContain @"..\Microsoft.Net.Http\lib\net40\System.Net.Http.dll" - - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) |> shouldContain @"..\Microsoft.Net.Http\lib\net40\System.Net.Http.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) |> shouldContain @"..\Microsoft.Net.Http\lib\net40\System.Net.Http.Primitives.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) |> shouldContain @"..\Microsoft.Net.Http\lib\net40\System.Net.Http.WebRequest.dll" - - model.GetLibReferences(SinglePlatform MonoAndroid) |> shouldContain @"..\Microsoft.Net.Http\lib\monoandroid\System.Net.Http.Extensions.dll" - model.GetLibReferences(SinglePlatform MonoAndroid) |> shouldContain @"..\Microsoft.Net.Http\lib\monoandroid\System.Net.Http.Primitives.dll" - - model.GetLibReferences(SinglePlatform MonoTouch) |> shouldContain @"..\Microsoft.Net.Http\lib\monotouch\System.Net.Http.Extensions.dll" - model.GetLibReferences(SinglePlatform MonoTouch) |> shouldContain @"..\Microsoft.Net.Http\lib\monotouch\System.Net.Http.Primitives.dll" - - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) |> shouldNotContain @"..\Microsoft.Net.Http\lib\net40\System.Net.Http.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) |> shouldContain @"..\Microsoft.Net.Http\lib\net45\System.Net.Http.Primitives.dll" - - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) |> shouldNotContain @"..\Microsoft.Net.Http\lib\net40\System.Net.Http.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) |> shouldContain @"..\Microsoft.Net.Http\lib\net45\System.Net.Http.Primitives.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) + |> Seq.map (fun f -> f.Path) |> shouldNotContain @"..\Microsoft.Net.Http\lib\net40\System.Net.Http.dll" + + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Net.Http\lib\net40\System.Net.Http.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Net.Http\lib\net40\System.Net.Http.Primitives.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Net.Http\lib\net40\System.Net.Http.WebRequest.dll" + + model.GetLibReferences(SinglePlatform MonoAndroid) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Net.Http\lib\monoandroid\System.Net.Http.Extensions.dll" + model.GetLibReferences(SinglePlatform MonoAndroid) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Net.Http\lib\monoandroid\System.Net.Http.Primitives.dll" + + model.GetLibReferences(SinglePlatform MonoTouch) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Net.Http\lib\monotouch\System.Net.Http.Extensions.dll" + model.GetLibReferences(SinglePlatform MonoTouch) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Net.Http\lib\monotouch\System.Net.Http.Primitives.dll" + + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) + |> Seq.map (fun f -> f.Path) |> shouldNotContain @"..\Microsoft.Net.Http\lib\net40\System.Net.Http.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Net.Http\lib\net45\System.Net.Http.Primitives.dll" + + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) + |> Seq.map (fun f -> f.Path) |> shouldNotContain @"..\Microsoft.Net.Http\lib\net40\System.Net.Http.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Net.Http\lib\net45\System.Net.Http.Primitives.dll" let profile88 = KnownTargetProfiles.FindPortableProfile "Profile88" - model.GetLibReferences(profile88) |> shouldContain @"..\Microsoft.Net.Http\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.dll" - model.GetLibReferences(profile88) |> shouldContain @"..\Microsoft.Net.Http\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.Extensions.dll" - model.GetLibReferences(profile88) |> shouldContain @"..\Microsoft.Net.Http\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.Primitives.dll" + model.GetLibReferences(profile88) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Net.Http\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.dll" + model.GetLibReferences(profile88) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Net.Http\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.Extensions.dll" + model.GetLibReferences(profile88) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Net.Http\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.Primitives.dll" let profile7 = KnownTargetProfiles.FindPortableProfile "Profile7" - model.GetLibReferences(profile7) |> shouldContain @"..\Microsoft.Net.Http\lib\portable-net45+win8\System.Net.Http.Extensions.dll" - model.GetLibReferences(profile7) |> shouldContain @"..\Microsoft.Net.Http\lib\portable-net45+win8\System.Net.Http.Primitives.dll" + model.GetLibReferences(profile7) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Net.Http\lib\portable-net45+win8\System.Net.Http.Extensions.dll" + model.GetLibReferences(profile7) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Net.Http\lib\portable-net45+win8\System.Net.Http.Primitives.dll" - model.GetLibReferences(SinglePlatform (Windows "v4.5")) |> shouldContain @"..\Microsoft.Net.Http\lib\win8\System.Net.Http.Extensions.dll" - model.GetLibReferences(SinglePlatform (Windows "v4.5")) |> shouldContain @"..\Microsoft.Net.Http\lib\win8\System.Net.Http.Primitives.dll" + model.GetLibReferences(SinglePlatform (Windows "v4.5")) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Net.Http\lib\win8\System.Net.Http.Extensions.dll" + model.GetLibReferences(SinglePlatform (Windows "v4.5")) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Net.Http\lib\win8\System.Net.Http.Primitives.dll" - model.GetLibReferences(SinglePlatform (WindowsPhoneApp "v8.1")) |> shouldContain @"..\Microsoft.Net.Http\lib\wpa81\System.Net.Http.Extensions.dll" - model.GetLibReferences(SinglePlatform (WindowsPhoneApp "v8.1")) |> shouldContain @"..\Microsoft.Net.Http\lib\wpa81\System.Net.Http.Primitives.dll" + model.GetLibReferences(SinglePlatform (WindowsPhoneApp "v8.1")) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Net.Http\lib\wpa81\System.Net.Http.Extensions.dll" + model.GetLibReferences(SinglePlatform (WindowsPhoneApp "v8.1")) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Net.Http\lib\wpa81\System.Net.Http.Primitives.dll" [] @@ -437,9 +542,12 @@ let ``should handle lib install of MicrosoftBcl``() = @"..\Microsoft.Bcl\lib\portable-net451+win81+wpa81\_._"] |> fromLegacyList @"..\Microsoft.Bcl\")).FilterBlackList() - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) |> shouldContain @"..\Microsoft.Bcl\lib\net40\System.IO.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) |> shouldContain @"..\Microsoft.Bcl\lib\net40\System.Runtime.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) |> shouldContain @"..\Microsoft.Bcl\lib\net40\System.Threading.Tasks.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Bcl\lib\net40\System.IO.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Bcl\lib\net40\System.Runtime.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Bcl\lib\net40\System.Threading.Tasks.dll" model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) |> shouldBeEmpty model.GetLibReferences(SinglePlatform MonoAndroid) |> shouldBeEmpty @@ -451,21 +559,33 @@ let ``should handle lib install of MicrosoftBcl``() = model.GetLibReferences(KnownTargetProfiles.FindPortableProfile "Profile151") |> shouldBeEmpty let profile41 = KnownTargetProfiles.FindPortableProfile "Profile41" - model.GetLibReferences(profile41) |> shouldContain @"..\Microsoft.Bcl\lib\portable-net40+sl4+win8\System.IO.dll" - model.GetLibReferences(profile41) |> shouldContain @"..\Microsoft.Bcl\lib\portable-net40+sl4+win8\System.Runtime.dll" - model.GetLibReferences(profile41) |> shouldContain @"..\Microsoft.Bcl\lib\portable-net40+sl4+win8\System.Threading.Tasks.dll" - - model.GetLibReferences(SinglePlatform (Silverlight "v4.0")) |> shouldContain @"..\Microsoft.Bcl\lib\sl4\System.IO.dll" - model.GetLibReferences(SinglePlatform (Silverlight "v4.0")) |> shouldContain @"..\Microsoft.Bcl\lib\sl4\System.Runtime.dll" - model.GetLibReferences(SinglePlatform (Silverlight "v4.0")) |> shouldContain @"..\Microsoft.Bcl\lib\sl4\System.Threading.Tasks.dll" + model.GetLibReferences(profile41) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Bcl\lib\portable-net40+sl4+win8\System.IO.dll" + model.GetLibReferences(profile41) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Bcl\lib\portable-net40+sl4+win8\System.Runtime.dll" + model.GetLibReferences(profile41) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Bcl\lib\portable-net40+sl4+win8\System.Threading.Tasks.dll" + + model.GetLibReferences(SinglePlatform (Silverlight "v4.0")) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Bcl\lib\sl4\System.IO.dll" + model.GetLibReferences(SinglePlatform (Silverlight "v4.0")) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Bcl\lib\sl4\System.Runtime.dll" + model.GetLibReferences(SinglePlatform (Silverlight "v4.0")) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Bcl\lib\sl4\System.Threading.Tasks.dll" - model.GetLibReferences(SinglePlatform (WindowsPhoneSilverlight "v7.1")) |> shouldContain @"..\Microsoft.Bcl\lib\sl4-windowsphone71\System.IO.dll" - model.GetLibReferences(SinglePlatform (WindowsPhoneSilverlight "v7.1")) |> shouldContain @"..\Microsoft.Bcl\lib\sl4-windowsphone71\System.Runtime.dll" - model.GetLibReferences(SinglePlatform (WindowsPhoneSilverlight "v7.1")) |> shouldContain @"..\Microsoft.Bcl\lib\sl4-windowsphone71\System.Threading.Tasks.dll" + model.GetLibReferences(SinglePlatform (WindowsPhoneSilverlight "v7.1")) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Bcl\lib\sl4-windowsphone71\System.IO.dll" + model.GetLibReferences(SinglePlatform (WindowsPhoneSilverlight "v7.1")) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Bcl\lib\sl4-windowsphone71\System.Runtime.dll" + model.GetLibReferences(SinglePlatform (WindowsPhoneSilverlight "v7.1")) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Bcl\lib\sl4-windowsphone71\System.Threading.Tasks.dll" - model.GetLibReferences(SinglePlatform (Silverlight "v5.0")) |> shouldContain @"..\Microsoft.Bcl\lib\sl5\System.IO.dll" - model.GetLibReferences(SinglePlatform (Silverlight "v5.0")) |> shouldContain @"..\Microsoft.Bcl\lib\sl5\System.Runtime.dll" - model.GetLibReferences(SinglePlatform (Silverlight "v5.0")) |> shouldContain @"..\Microsoft.Bcl\lib\sl5\System.Threading.Tasks.dll" + model.GetLibReferences(SinglePlatform (Silverlight "v5.0")) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Bcl\lib\sl5\System.IO.dll" + model.GetLibReferences(SinglePlatform (Silverlight "v5.0")) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Bcl\lib\sl5\System.Runtime.dll" + model.GetLibReferences(SinglePlatform (Silverlight "v5.0")) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Bcl\lib\sl5\System.Threading.Tasks.dll" [] @@ -476,17 +596,25 @@ let ``should handle lib install of Fantomas 1.5``() = @"..\Fantomas\lib\FSharp.Core.dll" @"..\Fantomas\lib\Fantomas.exe" ] |> fromLegacyList @"..\Fantomas\") - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V2)) |> shouldContain @"..\Fantomas\lib\FantomasLib.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V2)) |> shouldContain @"..\Fantomas\lib\FSharp.Core.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V2)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Fantomas\lib\FantomasLib.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V2)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Fantomas\lib\FSharp.Core.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) |> shouldContain @"..\Fantomas\lib\FantomasLib.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) |> shouldContain @"..\Fantomas\lib\FSharp.Core.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Fantomas\lib\FantomasLib.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Fantomas\lib\FSharp.Core.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) |> shouldContain @"..\Fantomas\lib\FantomasLib.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) |> shouldContain @"..\Fantomas\lib\FSharp.Core.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Fantomas\lib\FantomasLib.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Fantomas\lib\FSharp.Core.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) |> shouldContain @"..\Fantomas\lib\FantomasLib.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) |> shouldContain @"..\Fantomas\lib\FSharp.Core.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Fantomas\lib\FantomasLib.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Fantomas\lib\FSharp.Core.dll" [] let ``should handle lib install of Fantomas 1.5.0 with explicit references``() = @@ -497,17 +625,25 @@ let ``should handle lib install of Fantomas 1.5.0 with explicit references``() = @"..\Fantomas\lib\Fantomas.exe" ] |> fromLegacyList @"..\Fantomas\", NuspecReferences.Explicit ["FantomasLib.dll"]) - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V2)) |> shouldContain @"..\Fantomas\lib\FantomasLib.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V2)) |> shouldNotContain @"..\Fantomas\lib\FSharp.Core.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V2)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Fantomas\lib\FantomasLib.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V2)) + |> Seq.map (fun f -> f.Path) |> shouldNotContain @"..\Fantomas\lib\FSharp.Core.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) |> shouldContain @"..\Fantomas\lib\FantomasLib.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) |> shouldNotContain @"..\Fantomas\lib\FSharp.Core.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Fantomas\lib\FantomasLib.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) + |> Seq.map (fun f -> f.Path) |> shouldNotContain @"..\Fantomas\lib\FSharp.Core.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) |> shouldContain @"..\Fantomas\lib\FantomasLib.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) |> shouldNotContain @"..\Fantomas\lib\FSharp.Core.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Fantomas\lib\FantomasLib.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) + |> Seq.map (fun f -> f.Path) |> shouldNotContain @"..\Fantomas\lib\FSharp.Core.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) |> shouldContain @"..\Fantomas\lib\FantomasLib.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) |> shouldNotContain @"..\Fantomas\lib\FSharp.Core.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Fantomas\lib\FantomasLib.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) + |> Seq.map (fun f -> f.Path) |> shouldNotContain @"..\Fantomas\lib\FSharp.Core.dll" [] @@ -521,10 +657,14 @@ let ``should only handle dll and exe files``() = NuspecReferences.All) .FilterBlackList() - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V2)) |> shouldContain @"..\Fantomas\lib\FantomasLib.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V2)) |> shouldContain @"..\Fantomas\lib\FSharp.Core.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V2)) |> shouldContain @"..\Fantomas\lib\Fantomas.exe" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V2)) |> shouldNotContain @"..\Fantomas\lib\FantomasLib.xml" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V2)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Fantomas\lib\FantomasLib.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V2)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Fantomas\lib\FSharp.Core.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V2)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Fantomas\lib\Fantomas.exe" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V2)) + |> Seq.map (fun f -> f.Path) |> shouldNotContain @"..\Fantomas\lib\FantomasLib.xml" [] let ``should use portable net40 in net45 when don't have other files``() = @@ -533,11 +673,16 @@ let ``should use portable net40 in net45 when don't have other files``() = [ @"..\Google.Apis.Core\lib\portable-net40+sl50+win+wpa81+wp80\Google.Apis.Core.dll" ] |> fromLegacyList @"..\Google.Apis.Core\", NuspecReferences.All) - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) |> shouldContain @"..\Google.Apis.Core\lib\portable-net40+sl50+win+wpa81+wp80\Google.Apis.Core.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) |> shouldContain @"..\Google.Apis.Core\lib\portable-net40+sl50+win+wpa81+wp80\Google.Apis.Core.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5_1)) |> shouldContain @"..\Google.Apis.Core\lib\portable-net40+sl50+win+wpa81+wp80\Google.Apis.Core.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5_2)) |> shouldContain @"..\Google.Apis.Core\lib\portable-net40+sl50+win+wpa81+wp80\Google.Apis.Core.dll" - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5_3)) |> shouldContain @"..\Google.Apis.Core\lib\portable-net40+sl50+win+wpa81+wp80\Google.Apis.Core.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Google.Apis.Core\lib\portable-net40+sl50+win+wpa81+wp80\Google.Apis.Core.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Google.Apis.Core\lib\portable-net40+sl50+win+wpa81+wp80\Google.Apis.Core.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5_1)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Google.Apis.Core\lib\portable-net40+sl50+win+wpa81+wp80\Google.Apis.Core.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5_2)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Google.Apis.Core\lib\portable-net40+sl50+win+wpa81+wp80\Google.Apis.Core.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_5_3)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Google.Apis.Core\lib\portable-net40+sl50+win+wpa81+wp80\Google.Apis.Core.dll" [] let ``should not install tools``() = @@ -548,7 +693,7 @@ let ``should not install tools``() = @"..\FAKE\tools\Fake.SQL.dll" ] |> fromLegacyList @"..\FAKE\") model.CompileLibFolders - |> Seq.forall (fun folder -> folder.Files.References.IsEmpty) + |> Seq.forall (fun folder -> folder.FolderContents.Libraries.IsEmpty && folder.FolderContents.FrameworkReferences.IsEmpty) |> shouldEqual true [] @@ -559,7 +704,8 @@ let ``should handle props files``() = @"..\xunit.runner.visualstudio\build\portable-net45+aspnetcore50+win+wpa81+wp80+monotouch+monoandroid\xunit.runner.visualstudio.props" ] |> fromLegacyList @"..\xunit.runner.visualstudio\") .FilterBlackList() - model.GetTargetsFiles(SinglePlatform (DotNetFramework FrameworkVersion.V2)) |> shouldContain @"..\xunit.runner.visualstudio\build\net20\xunit.runner.visualstudio.props" + model.GetTargetsFiles(SinglePlatform (DotNetFramework FrameworkVersion.V2)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\xunit.runner.visualstudio\build\net20\xunit.runner.visualstudio.props" [] let ``should handle Targets files``() = @@ -568,15 +714,16 @@ let ``should handle Targets files``() = [ @"..\StyleCop.MSBuild\build\StyleCop.MSBuild.Targets" ] |> fromLegacyList @"..\StyleCop.MSBuild\") .FilterBlackList() - model.GetTargetsFiles(SinglePlatform (DotNetFramework FrameworkVersion.V2)) |> shouldContain @"..\StyleCop.MSBuild\build\StyleCop.MSBuild.Targets" + model.GetTargetsFiles(SinglePlatform (DotNetFramework FrameworkVersion.V2)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\StyleCop.MSBuild\build\StyleCop.MSBuild.Targets" [] let ``should filter .NET 4.0 dlls for System.Net.Http 2.2.8``() = let expected = - [ @"..\Microsoft.Net.Http\lib\net40\System.Net.Http.Extensions.dll" + [ @"..\Microsoft.Net.Http\lib\net40\System.Net.Http.dll" + @"..\Microsoft.Net.Http\lib\net40\System.Net.Http.Extensions.dll" @"..\Microsoft.Net.Http\lib\net40\System.Net.Http.Primitives.dll" - @"..\Microsoft.Net.Http\lib\net40\System.Net.Http.WebRequest.dll" - @"..\Microsoft.Net.Http\lib\net40\System.Net.Http.dll" ] + @"..\Microsoft.Net.Http\lib\net40\System.Net.Http.WebRequest.dll" ] |> Seq.ofList let model = @@ -604,6 +751,7 @@ let ``should filter .NET 4.0 dlls for System.Net.Http 2.2.8``() = @"..\Microsoft.Net.Http\lib\wpa81\System.Net.Http.Primitives.dll" ] |> fromLegacyList @"..\Microsoft.Net.Http\", [], [], Nuspec.All) model.GetLibReferences(SinglePlatform(DotNetFramework(FrameworkVersion.V4))) + |> Seq.map (fun f -> f.Path) |> shouldEqual expected [] @@ -638,9 +786,11 @@ let ``should filter .NET 4.5 dlls for System.Net.Http 2.2.8``() = @"..\Microsoft.Net.Http\lib\wpa81\System.Net.Http.Primitives.dll" ] |> fromLegacyList @"..\Microsoft.Net.Http\", [], [], Nuspec.All) model.GetLibReferences(SinglePlatform(DotNetFramework(FrameworkVersion.V4_5))) + |> Seq.map (fun f -> f.Path) |> shouldEqual expected model.GetLibReferences(SinglePlatform(DotNetFramework(FrameworkVersion.V4_5_2))) + |> Seq.map (fun f -> f.Path) |> shouldEqual expected [] @@ -660,6 +810,7 @@ let ``should filter properly when portables are available``() = model.ApplyFrameworkRestrictions ( [ FrameworkRestriction.Exactly (FrameworkIdentifier.DotNetFramework FrameworkVersion.V4_5) ] ) filteredModel.GetLibReferences(SinglePlatform(DotNetFramework(FrameworkVersion.V4_5))) + |> Seq.map (fun f -> f.Path) |> Seq.toList |> shouldEqual [ @"..\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll" ] @@ -679,10 +830,12 @@ let ``should keep net20 if nothing better is available``() = model.ApplyFrameworkRestrictions ( [ FrameworkRestriction.Exactly (FrameworkIdentifier.DotNetFramework FrameworkVersion.V4_6_1) ] ) filteredModel.GetLibReferences(SinglePlatform(DotNetFramework(FrameworkVersion.V4_6_1))) + |> Seq.map (fun f -> f.Path) |> Seq.toList |> shouldEqual [ @"..\EPPlus\lib\net20\EPPlus.dll" ] filteredModel.GetLibReferences(SinglePlatform(DotNetFramework(FrameworkVersion.V4))) + |> Seq.map (fun f -> f.Path) |> Seq.toList |> shouldEqual [ ] @@ -699,6 +852,7 @@ let ``prefer net20 over empty folder``() = model.ApplyFrameworkRestrictions ( [ FrameworkRestriction.Exactly (FrameworkIdentifier.DotNetFramework FrameworkVersion.V4_6_1) ] ) filteredModel.GetLibReferences(SinglePlatform(DotNetFramework(FrameworkVersion.V4_6_1))) + |> Seq.map (fun f -> f.Path) |> Seq.toList |> shouldEqual [ @"..\EPPlus\lib\net20\EPPlus.dll" ] @@ -711,4 +865,5 @@ let ``should understand xamarinios``() = let model = emptymodel.ApplyFrameworkRestrictions ([FrameworkRestriction.Exactly (XamariniOS)]) let model = model.AddReferences ([ @"..\FSharp.Core\lib\portable-net45+monoandroid10+monotouch10+xamarinios10\FSharp.Core.dll" ] |> fromLegacyList @"..\FSharp.Core\") - model.GetLibReferences(SinglePlatform (XamariniOS)) |> shouldContain @"..\FSharp.Core\lib\portable-net45+monoandroid10+monotouch10+xamarinios10\FSharp.Core.dll" \ No newline at end of file + model.GetLibReferences(SinglePlatform (XamariniOS)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\FSharp.Core\lib\portable-net45+monoandroid10+monotouch10+xamarinios10\FSharp.Core.dll" \ No newline at end of file diff --git a/tests/Paket.Tests/InstallModel/Xml/LibGit2Sharp.fs b/tests/Paket.Tests/InstallModel/Xml/LibGit2Sharp.fs index 8c132dae08..029b6a78ec 100644 --- a/tests/Paket.Tests/InstallModel/Xml/LibGit2Sharp.fs +++ b/tests/Paket.Tests/InstallModel/Xml/LibGit2Sharp.fs @@ -44,7 +44,8 @@ let ``should generate Xml for LibGit2Sharp 2.0.0``() = [], Nuspec.All) - model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_Client)) |> shouldContain @"..\LibGit2Sharp\lib\net40\LibGit2Sharp.dll" + model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_Client)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\LibGit2Sharp\lib\net40\LibGit2Sharp.dll" let ctx = ProjectFile.TryLoad("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model, System.Collections.Generic.HashSet<_>(),Map.empty,Some true,true,KnownTargetProfiles.AllProfiles,None) ctx.ChooseNodes.Head.OuterXml diff --git a/tests/Paket.Tests/InstallModel/Xml/Microsoft.Bcl.Build.fs b/tests/Paket.Tests/InstallModel/Xml/Microsoft.Bcl.Build.fs index 38fa793757..8307878950 100644 --- a/tests/Paket.Tests/InstallModel/Xml/Microsoft.Bcl.Build.fs +++ b/tests/Paket.Tests/InstallModel/Xml/Microsoft.Bcl.Build.fs @@ -17,7 +17,8 @@ let ``should not install targets node for Microsoft.Bcl.Build``() = [], Nuspec.All) - model.GetTargetsFiles(SinglePlatform (DotNetFramework FrameworkVersion.V4)) |> shouldContain @"..\Microsoft.Bcl.Build\build\Microsoft.Bcl.Build.targets" + model.GetTargetsFiles(SinglePlatform (DotNetFramework FrameworkVersion.V4)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\Microsoft.Bcl.Build\build\Microsoft.Bcl.Build.targets" let ctx = ProjectFile.TryLoad("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model, System.Collections.Generic.HashSet<_>(),Map.empty,Some true,false,KnownTargetProfiles.AllProfiles,None) diff --git a/tests/Paket.Tests/InstallModel/Xml/StyleCop.MSBuild.fs b/tests/Paket.Tests/InstallModel/Xml/StyleCop.MSBuild.fs index 51c386cbc0..1bb145d462 100644 --- a/tests/Paket.Tests/InstallModel/Xml/StyleCop.MSBuild.fs +++ b/tests/Paket.Tests/InstallModel/Xml/StyleCop.MSBuild.fs @@ -22,7 +22,8 @@ let ``should generate Xml for StyleCop.MSBuild``() = [], Nuspec.All) - model.GetTargetsFiles(SinglePlatform (DotNetFramework FrameworkVersion.V2)) |> shouldContain @"..\StyleCop.MSBuild\build\StyleCop.MSBuild.Targets" + model.GetTargetsFiles(SinglePlatform (DotNetFramework FrameworkVersion.V2)) + |> Seq.map (fun f -> f.Path) |> shouldContain @"..\StyleCop.MSBuild\build\StyleCop.MSBuild.Targets" let ctx = ProjectFile.TryLoad("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model, System.Collections.Generic.HashSet<_>(),Map.empty,Some true,true,KnownTargetProfiles.AllProfiles,None) From dad17aee566633e0dafc2c51e4905f4dbe40a63c Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Wed, 19 Apr 2017 09:55:24 +0200 Subject: [PATCH 23/30] write some release notes --- RELEASE_NOTES.md | 10 +++++ .../FrameworkRestrictionsSpecs.fs | 1 + src/Paket.Core/InstallModel.fs | 38 ++++++++++--------- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index faa2862c92..bf2387a393 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,13 @@ +#### 5.0.0-alpha001 - 19.04.2017 +* Fix dotnetcore integration. + * Paket now properly understands runtime and reference assemblies + * Paket now understands the runtime graph and restores runtime dependencies + * New API `InstallModel.GetRuntimeAssemblies` and `InstallModel.GetRuntimeLibraries` can be used to retrieve the correct assets for a particular RID and TFM +* New command `paket generate-nuspec` +* BREAKS: `InstallModel` API +* BUGFIX: Improved C++ support + + #### 4.4.1 - 17.04.2017 * Support Netstandard 2.0 * Support Netframework 4.7 diff --git a/integrationtests/Paket.IntegrationTests/FrameworkRestrictionsSpecs.fs b/integrationtests/Paket.IntegrationTests/FrameworkRestrictionsSpecs.fs index 2b37c33b75..d0b34b169d 100644 --- a/integrationtests/Paket.IntegrationTests/FrameworkRestrictionsSpecs.fs +++ b/integrationtests/Paket.IntegrationTests/FrameworkRestrictionsSpecs.fs @@ -24,6 +24,7 @@ let ``#1182 framework restrictions overwrite each other``() = lockFile.Contains("framework: winv4.5") |> shouldEqual false [] +[] // PATH TOO LONG on Windows... let ``#1190 paket add nuget should handle transitive dependencies``() = paket "add nuget xunit version 2.1.0" "i001190-transitive-dependencies-with-restr" |> ignore diff --git a/src/Paket.Core/InstallModel.fs b/src/Paket.Core/InstallModel.fs index 57fe4bb6cf..9e560d928a 100644 --- a/src/Paket.Core/InstallModel.fs +++ b/src/Paket.Core/InstallModel.fs @@ -91,7 +91,8 @@ type InstallModel = PackageVersion : SemVerInfo CompileLibFolders : LibFolder list CompileRefFolders : LibFolder list - RuntimeLibFolders : LibFolder list + //RuntimeLibFolders : LibFolder list + RuntimeAssemblyFolders : LibFolder list TargetsFileFolders : LibFolder list Analyzers: AnalyzerLib list LicenseUrl: string option } @@ -298,7 +299,8 @@ module InstallModel = PackageVersion = packageVersion CompileLibFolders = [] CompileRefFolders = [] - RuntimeLibFolders = [] + //RuntimeLibFolders = [] + RuntimeAssemblyFolders = [] TargetsFileFolders = [] Analyzers = [] LicenseUrl = None } @@ -420,8 +422,8 @@ module InstallModel = getLegacyReferences target installModel else results - let getRuntimeLibraries graph rid (target : TargetProfile) (installModel:InstallModel) = - getFileFolders target (installModel.RuntimeLibFolders) (fun f -> f |> Set.toSeq) + let getRuntimeAssemblies graph rid (target : TargetProfile) (installModel:InstallModel) = + getFileFolders target (installModel.RuntimeAssemblyFolders) (fun f -> f |> Set.toSeq) |> Seq.cache let getTargetsFiles (target : TargetProfile) (installModel:InstallModel) = @@ -437,7 +439,7 @@ module InstallModel = |> Seq.forall Set.isEmpty let removeIfCompletelyEmpty (this:InstallModel) = let foldersEmpty = - isEmpty this.CompileRefFolders && isEmpty this.TargetsFileFolders && isEmpty this.RuntimeLibFolders && + isEmpty this.CompileRefFolders && isEmpty this.TargetsFileFolders && isEmpty this.RuntimeAssemblyFolders && this.CompileLibFolders |> Seq.map (fun c -> c.FolderContents.Libraries |> Set.toSeq, c.FolderContents.FrameworkReferences |> Set.toSeq) |> Seq.forall (fun (libs, refs) -> Seq.isEmpty libs && Seq.isEmpty refs) @@ -459,7 +461,7 @@ module InstallModel = let calcLegacyReferenceLibFolders = calcLibFoldersG ReferenceOrLibraryFolder.empty getCompileLibAssembly let calcReferenceFolders = calcLibFoldersG Set.empty getCompileRefAssembly - let calcRuntimeFolders = calcLibFoldersG Set.empty getRuntimeAssembly + let calcRuntimeAssemblyFolders = calcLibFoldersG Set.empty getRuntimeAssembly //let calcRefFolders = calcLibFoldersG extractRefFolder let addFileToFolder<'T, 'Item> (path:LibFolder<'T>) (file:'Item) (folders:LibFolder<'T> list) (addfn: 'Item -> 'T -> 'T) = @@ -487,7 +489,7 @@ module InstallModel = { this with CompileRefFolders = addFileToFolder path (Library.ofFile file) this.CompileRefFolders Set.add } - let private addPackageRuntimeFile references (path:LibFolder) (file:UnparsedPackageFile) (this:InstallModel) : InstallModel = + let private addPackageRuntimeAssemblyFile references (path:LibFolder) (file:UnparsedPackageFile) (this:InstallModel) : InstallModel = let install = match references with | NuspecReferences.All -> true @@ -495,7 +497,7 @@ module InstallModel = if not install then this else { this with - RuntimeLibFolders = addFileToFolder path (Library.ofFile file) this.RuntimeLibFolders Set.add } + RuntimeAssemblyFolders = addFileToFolder path (Library.ofFile file) this.RuntimeAssemblyFolders Set.add } let private addItem libs extract addFunc getFolder initialState = List.fold (fun (model:InstallModel) file -> @@ -510,15 +512,15 @@ module InstallModel = let libs = libs |> Seq.toList let legacyLibFolders = calcLegacyReferenceLibFolders libs let refFolders = calcReferenceFolders libs - let runtimeFolders = calcRuntimeFolders libs + let runtimeAssemblyFolders = calcRuntimeAssemblyFolders libs { installModel with CompileLibFolders = legacyLibFolders CompileRefFolders = refFolders - RuntimeLibFolders = runtimeFolders } + RuntimeAssemblyFolders = runtimeAssemblyFolders } |> addItem libs getCompileLibAssembly (addPackageLegacyLibFile references) (fun i -> i.CompileLibFolders) |> addItem libs getCompileRefAssembly (addPackageRefFile references) (fun i -> i.CompileRefFolders) - |> addItem libs getRuntimeAssembly (addPackageRuntimeFile references) (fun i -> i.RuntimeLibFolders) + |> addItem libs getRuntimeAssembly (addPackageRuntimeAssemblyFile references) (fun i -> i.RuntimeAssemblyFolders) let addAnalyzerFiles (analyzerFiles:UnparsedPackageFile seq) (installModel:InstallModel) : InstallModel = let analyzerLibs = @@ -545,9 +547,9 @@ module InstallModel = let mapCompileRefFolders mapfn (installModel:InstallModel) = { installModel with CompileRefFolders = List.map mapfn installModel.CompileRefFolders } - let mapRuntimeLibFolders mapfn (installModel:InstallModel) = + let mapRuntimeAssemblyFolders mapfn (installModel:InstallModel) = { installModel with - RuntimeLibFolders = List.map mapfn installModel.RuntimeLibFolders } + RuntimeAssemblyFolders = List.map mapfn installModel.RuntimeAssemblyFolders } let mapTargetsFileFolders mapfn (installModel:InstallModel) = { installModel with TargetsFileFolders = List.map mapfn installModel.TargetsFileFolders } @@ -558,8 +560,8 @@ module InstallModel = mapCompileLibFolders (LibFolder.map (fun l -> { l with Libraries = mapfn l.Libraries })) installModel let mapCompileRefFiles mapfn (installModel:InstallModel) = mapCompileRefFolders (LibFolder.map (mapfn)) installModel - let mapRuntimeLibFiles mapfn (installModel:InstallModel) = - mapRuntimeLibFolders (LibFolder.map (mapfn)) installModel + let mapRuntimeAssemblyFiles mapfn (installModel:InstallModel) = + mapRuntimeAssemblyFolders (LibFolder.map (mapfn)) installModel let mapTargetsFiles mapfn (installModel:InstallModel) = mapTargetsFileFolders (LibFolder.map (mapfn)) installModel @@ -646,8 +648,8 @@ module InstallModel = |> List.map applyRestriction |> List.filter (fun folder -> folder.Targets <> []) - RuntimeLibFolders = - installModel.RuntimeLibFolders + RuntimeAssemblyFolders = + installModel.RuntimeAssemblyFolders |> List.map applyRestriction |> List.filter (fun folder -> folder.Targets <> []) @@ -703,6 +705,8 @@ type InstallModel with member this.GetLibReferences target = InstallModel.getLegacyReferences target this member this.GetLegacyReferences target = InstallModel.getLegacyReferences target this member this.GetCompileReferences target = InstallModel.getCompileReferences target this + member this.GetRuntimeAssemblies graph rid target = InstallModel.getRuntimeAssemblies graph rid target this + // TODO: member this.GetRuntimeLibraries graph rid target = InstallModel.getRuntimeLibraries graph rid target this [] From e81cda93c8167e5f907e159e56e22f88ec19e2c4 Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Wed, 19 Apr 2017 10:25:55 +0200 Subject: [PATCH 24/30] more runtime support in installmodel --- src/Paket.Core/InstallModel.fs | 59 ++++++++++--------- .../InstallModel/ProcessingSpecs.fs | 31 +++++----- 2 files changed, 48 insertions(+), 42 deletions(-) diff --git a/src/Paket.Core/InstallModel.fs b/src/Paket.Core/InstallModel.fs index 9e560d928a..eb0d2d4723 100644 --- a/src/Paket.Core/InstallModel.fs +++ b/src/Paket.Core/InstallModel.fs @@ -9,24 +9,29 @@ open PlatformMatching open ProviderImplementation.AssemblyReader.Utils.SHA1 type UnparsedPackageFile = Paket.NuGet.UnparsedPackageFile - +type Tfm = PlatformMatching.ParsedPlatformPath +//type Rid = Paket.Rid +type FrameworkDependentFile = + { Path : Tfm + File : UnparsedPackageFile + Runtime : Rid } type Library = { Name : string Path : string } module Library = - let ofFile (f:UnparsedPackageFile) = - let fi = FileInfo(normalizePath f.FullPath) + let ofFile (f:FrameworkDependentFile) = + let fi = FileInfo(normalizePath f.File.FullPath) let name = fi.Name.Replace(fi.Extension, "") - { Name = name; Path = f.FullPath } + { Name = name; Path = f.File.FullPath } type MsBuildFile = { Name : string Path : string } module MsBuildFile = - let ofFile (f:UnparsedPackageFile) = - let fi = FileInfo(normalizePath f.FullPath) + let ofFile (f:FrameworkDependentFile) = + let fi = FileInfo(normalizePath f.File.FullPath) let name = fi.Name.Replace(fi.Extension, "") - { Name = name; Path = f.FullPath } + { Name = name; Path = f.File.FullPath } type FrameworkReference = { Name : string } @@ -91,7 +96,7 @@ type InstallModel = PackageVersion : SemVerInfo CompileLibFolders : LibFolder list CompileRefFolders : LibFolder list - //RuntimeLibFolders : LibFolder list + RuntimeLibFolders : LibFolder list RuntimeAssemblyFolders : LibFolder list TargetsFileFolders : LibFolder list Analyzers: AnalyzerLib list @@ -299,7 +304,7 @@ module InstallModel = PackageVersion = packageVersion CompileLibFolders = [] CompileRefFolders = [] - //RuntimeLibFolders = [] + RuntimeLibFolders = [] RuntimeAssemblyFolders = [] TargetsFileFolders = [] Analyzers = [] @@ -317,11 +322,6 @@ module InstallModel = let trySscanf pf s = FolderScanner.trySscanfExt scanners { FolderScanner.ScanOptions.Default with IgnoreCase = true } pf s - type FrameworkDependentFile = - { Path : Tfm - File : UnparsedPackageFile - Runtime : Rid } - let getCompileRefAssembly (p:UnparsedPackageFile) = (trySscanf "ref/%A{tfm}/%A{noSeperator}" p.PathWithinPackage : (Tfm * string) option) |> Option.map (fun (l,_) -> { Path = l; File = p; Runtime = Rid.Any }) @@ -422,10 +422,16 @@ module InstallModel = getLegacyReferences target installModel else results - let getRuntimeAssemblies graph rid (target : TargetProfile) (installModel:InstallModel) = + let getRuntimeAssemblies (graph:RuntimeGraph) (rid:Rid) (target : TargetProfile) (installModel:InstallModel) = getFileFolders target (installModel.RuntimeAssemblyFolders) (fun f -> f |> Set.toSeq) |> Seq.cache + let getRuntimeLibraries (graph:RuntimeGraph) (rid:Rid) (installModel:InstallModel) = + Seq.empty + // TODO: todo + //getFileFolders target (installModel.RuntimeAssemblyFolders) (fun f -> f |> Set.toSeq) + //|> Seq.cache + let getTargetsFiles (target : TargetProfile) (installModel:InstallModel) = getFileFolders target installModel.TargetsFileFolders (fun f -> f |> Set.toSeq) @@ -470,30 +476,30 @@ module InstallModel = if p.Path <> path.Path then p else { p with FolderContents = addfn file p.FolderContents }) - let private addPackageLegacyLibFile references (path:LibFolder) (file:UnparsedPackageFile) (this:InstallModel) : InstallModel = + let private addPackageLegacyLibFile references (path:LibFolder) (file:FrameworkDependentFile) (this:InstallModel) : InstallModel = let install = match references with | NuspecReferences.All -> true - | NuspecReferences.Explicit list -> List.exists file.FullPath.EndsWith list + | NuspecReferences.Explicit list -> List.exists file.File.FullPath.EndsWith list if not install then this else { this with CompileLibFolders = addFileToFolder path (Library.ofFile file) this.CompileLibFolders ReferenceOrLibraryFolder.addLibrary } - let private addPackageRefFile references (path:LibFolder) (file:UnparsedPackageFile) (this:InstallModel) : InstallModel = + let private addPackageRefFile references (path:LibFolder) (file:FrameworkDependentFile) (this:InstallModel) : InstallModel = let install = match references with | NuspecReferences.All -> true - | NuspecReferences.Explicit list -> List.exists file.FullPath.EndsWith list + | NuspecReferences.Explicit list -> List.exists file.File.FullPath.EndsWith list if not install then this else { this with CompileRefFolders = addFileToFolder path (Library.ofFile file) this.CompileRefFolders Set.add } - let private addPackageRuntimeAssemblyFile references (path:LibFolder) (file:UnparsedPackageFile) (this:InstallModel) : InstallModel = + let private addPackageRuntimeAssemblyFile references (path:LibFolder) (file:FrameworkDependentFile) (this:InstallModel) : InstallModel = let install = match references with | NuspecReferences.All -> true - | NuspecReferences.Explicit list -> List.exists file.FullPath.EndsWith list + | NuspecReferences.Explicit list -> List.exists file.File.FullPath.EndsWith list if not install then this else { this with @@ -502,9 +508,9 @@ module InstallModel = let private addItem libs extract addFunc getFolder initialState = List.fold (fun (model:InstallModel) file -> match extract file with - | Some (folderName:FrameworkDependentFile) -> - match List.tryFind (fun (folder:LibFolder<_>) -> folder.Path = folderName.Path) (getFolder model) with - | Some path -> addFunc path file model + | Some (parsedFile:FrameworkDependentFile) -> + match List.tryFind (fun (folder:LibFolder<_>) -> folder.Path = parsedFile.Path) (getFolder model) with + | Some path -> addFunc path parsedFile model | _ -> model | None -> model) initialState libs @@ -531,7 +537,7 @@ module InstallModel = { installModel with Analyzers = installModel.Analyzers @ analyzerLibs} - let rec addTargetsFile (path:LibFolder<_>) (file:UnparsedPackageFile) (installModel:InstallModel) :InstallModel = + let rec addTargetsFile (path:LibFolder<_>) (file:FrameworkDependentFile) (installModel:InstallModel) :InstallModel = { installModel with TargetsFileFolders = addFileToFolder path (MsBuildFile.ofFile file) installModel.TargetsFileFolders Set.add } @@ -706,8 +712,7 @@ type InstallModel with member this.GetLegacyReferences target = InstallModel.getLegacyReferences target this member this.GetCompileReferences target = InstallModel.getCompileReferences target this member this.GetRuntimeAssemblies graph rid target = InstallModel.getRuntimeAssemblies graph rid target this - // TODO: - member this.GetRuntimeLibraries graph rid target = InstallModel.getRuntimeLibraries graph rid target this + member this.GetRuntimeLibraries graph rid = InstallModel.getRuntimeLibraries graph rid this [] member this.GetLibReferences frameworkIdentifier = InstallModel.getLegacyPlatformReferences frameworkIdentifier this diff --git a/tests/Paket.Tests/InstallModel/ProcessingSpecs.fs b/tests/Paket.Tests/InstallModel/ProcessingSpecs.fs index 705774e82e..9b07a9adc8 100644 --- a/tests/Paket.Tests/InstallModel/ProcessingSpecs.fs +++ b/tests/Paket.Tests/InstallModel/ProcessingSpecs.fs @@ -135,21 +135,22 @@ let ``should understand reference folder``() = refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\lib\netstandard1.6\System.Security.Cryptography.Algorithms.dll" refs |> shouldContain @"..\System.Security.Cryptography.Algorithms\ref\netstandard1.6\System.Security.Cryptography.Algorithms.dll" - let refs = - model.GetRuntimeLibraries null null (SinglePlatform (DotNetStandard DotNetStandardVersion.V1_6)) - |> Seq.map (fun f -> f.Path) - refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\runtimes\win\lib\net46\System.Security.Cryptography.Algorithms.dll" - refs |> shouldContain @"..\System.Security.Cryptography.Algorithms\lib\netstandard1.6\System.Security.Cryptography.Algorithms.dll" - refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\ref\netstandard1.6\System.Security.Cryptography.Algorithms.dll" - - let refs = - model.GetRuntimeLibraries null null(SinglePlatform (DotNetFramework FrameworkVersion.V4_6_3)) - |> Seq.map (fun f -> f.Path) - refs |> shouldContain @"..\System.Security.Cryptography.Algorithms\runtimes\win\lib\net46\System.Security.Cryptography.Algorithms.dll" - // TODO: This is kind of broken for now -> the correct results depends on the runtime we want to get the runtime libraries for - // therefore GetRuntimeLibraries needs an additional parameter... - refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\lib\netstandard1.6\System.Security.Cryptography.Algorithms.dll" - refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\ref\netstandard1.6\System.Security.Cryptography.Algorithms.dll" + // TODO: + //let refs = + // model.GetRuntimeAssemblies RuntimeGraph.Empty null (SinglePlatform (DotNetStandard DotNetStandardVersion.V1_6)) + // |> Seq.map (fun f -> f.Path) + //refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\runtimes\win\lib\net46\System.Security.Cryptography.Algorithms.dll" + //refs |> shouldContain @"..\System.Security.Cryptography.Algorithms\lib\netstandard1.6\System.Security.Cryptography.Algorithms.dll" + //refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\ref\netstandard1.6\System.Security.Cryptography.Algorithms.dll" + // + //let refs = + // model.GetRuntimeAssemblies null null(SinglePlatform (DotNetFramework FrameworkVersion.V4_6_3)) + // |> Seq.map (fun f -> f.Path) + //refs |> shouldContain @"..\System.Security.Cryptography.Algorithms\runtimes\win\lib\net46\System.Security.Cryptography.Algorithms.dll" + //// TODO: This is kind of broken for now -> the correct results depends on the runtime we want to get the runtime libraries for + //// therefore GetRuntimeLibraries needs an additional parameter... + //refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\lib\netstandard1.6\System.Security.Cryptography.Algorithms.dll" + //refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\ref\netstandard1.6\System.Security.Cryptography.Algorithms.dll" //[] //let ``should understand aot in runtimes``() = From 2a4eb543690ba612d1c21013d96be1fc8681aa3c Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Wed, 19 Apr 2017 10:26:14 +0200 Subject: [PATCH 25/30] appveyor, please build a package for me and publish it. --- appveyor.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 4bab5e2a36..39c3336fde 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,9 +2,22 @@ image: Visual Studio 2017 init: - git config --global core.autocrlf input build_script: - - cmd: build.cmd RunIntegrationTests + - cmd: build.cmd BuildPackage test: off version: 0.0.1.{build} artifacts: - path: bin name: bin + - path: temp + name: nuget +nuget: + account_feed: false + project_feed: true +deploy: + provider: NuGet + #server: # remove to push to NuGet.org + #api_key: + # secure: m49OJ7+Jdt9an3jPcTukHA== + #skip_symbols: false + #symbol_server: # remove to push symbols to SymbolSource.org + artifact: /temp/.*\.nupkg/ From 35e28f3dc13e4ba91ad70a0082c4bfd1ad87d64b Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Wed, 19 Apr 2017 12:16:19 +0200 Subject: [PATCH 26/30] finish runtime support in installmodel, fix exlude support --- src/Paket.Core/Files/ProjectFile.fs | 2 +- src/Paket.Core/InstallModel.fs | 183 +++++++++++++----- src/Paket/Paket.fsproj | 4 +- .../InstallModel/ProcessingSpecs.fs | 62 +++--- 4 files changed, 168 insertions(+), 83 deletions(-) diff --git a/src/Paket.Core/Files/ProjectFile.fs b/src/Paket.Core/Files/ProjectFile.fs index fd2dfebbed..f2739954ed 100644 --- a/src/Paket.Core/Files/ProjectFile.fs +++ b/src/Paket.Core/Files/ProjectFile.fs @@ -748,7 +748,7 @@ module ProjectFile = // handle legacy conditions let conditions = - (model.GetReferenceFolders() @ (List.map (LibFolder.map (fun refs -> { ReferenceOrLibraryFolder.empty with Libraries = refs })) netCoreRestricted.CompileRefFolders)) + (model.GetReferenceFolders() @ (List.map (FrameworkFolder.map (fun refs -> { ReferenceOrLibraryFolder.empty with Libraries = refs })) netCoreRestricted.CompileRefFolders)) |> List.sortBy (fun libFolder -> libFolder.Path) |> List.collect (fun libFolder -> match libFolder with diff --git a/src/Paket.Core/InstallModel.fs b/src/Paket.Core/InstallModel.fs index eb0d2d4723..903c8374f9 100644 --- a/src/Paket.Core/InstallModel.fs +++ b/src/Paket.Core/InstallModel.fs @@ -14,15 +14,23 @@ type Tfm = PlatformMatching.ParsedPlatformPath type FrameworkDependentFile = { Path : Tfm File : UnparsedPackageFile - Runtime : Rid } + Runtime : Rid option } type Library = { Name : string - Path : string } + Path : string + PathWithinPackage : string } module Library = let ofFile (f:FrameworkDependentFile) = let fi = FileInfo(normalizePath f.File.FullPath) let name = fi.Name.Replace(fi.Extension, "") - { Name = name; Path = f.File.FullPath } + { Name = name; Path = f.File.FullPath; PathWithinPackage = f.File.PathWithinPackage } + +type RuntimeLibrary = + { Library : Library + Rid : Rid option } +module RuntimeLibrary = + let ofFile (f:FrameworkDependentFile) = + { Library = Library.ofFile f; Rid = f.Runtime } type MsBuildFile = { Name : string @@ -50,7 +58,7 @@ module ReferenceOrLibraryFolder = { old with ReferenceOrLibraryFolder.FrameworkReferences = Set.add item old.FrameworkReferences } /// Represents a subfolder of a nuget package that provides files (content, references, etc) for one or more Target Profiles. This is a logical representation of the 'net45' folder in a NuGet package, for example. -type LibFolder<'T> = +type FrameworkFolder<'T> = { Path : ParsedPlatformPath Targets : TargetProfile list FolderContents : 'T } @@ -59,8 +67,8 @@ type LibFolder<'T> = this.Targets |> List.choose (function SinglePlatform t -> Some t | _ -> None) -module LibFolder = - let map f (l:LibFolder<_>) = +module FrameworkFolder = + let map f (l:FrameworkFolder<_>) = { Path = l.Path Targets = l.Targets FolderContents = f l.FolderContents } @@ -94,11 +102,11 @@ type AnalyzerLib = type InstallModel = { PackageName : PackageName PackageVersion : SemVerInfo - CompileLibFolders : LibFolder list - CompileRefFolders : LibFolder list - RuntimeLibFolders : LibFolder list - RuntimeAssemblyFolders : LibFolder list - TargetsFileFolders : LibFolder list + CompileLibFolders : FrameworkFolder list + CompileRefFolders : FrameworkFolder list + RuntimeAssemblyFolders : FrameworkFolder list + RuntimeLibFolders : FrameworkFolder list + TargetsFileFolders : FrameworkFolder list Analyzers: AnalyzerLib list LicenseUrl: string option } @@ -324,17 +332,17 @@ module InstallModel = let getCompileRefAssembly (p:UnparsedPackageFile) = (trySscanf "ref/%A{tfm}/%A{noSeperator}" p.PathWithinPackage : (Tfm * string) option) - |> Option.map (fun (l,_) -> { Path = l; File = p; Runtime = Rid.Any }) + |> Option.map (fun (l,_) -> { Path = l; File = p; Runtime = None }) let getRuntimeAssembly (p:UnparsedPackageFile) = (trySscanf "lib/%A{tfm}/%A{noSeperator}" p.PathWithinPackage : (Tfm * string) option) - |> Option.map (fun (l,_) -> { Path = l; File = p; Runtime = Rid.Any }) + |> Option.map (fun (l,_) -> { Path = l; File = p; Runtime = None }) |> Option.orElseWith (fun _ -> (trySscanf "runtimes/%A{rid}/lib/%A{tfm}/%A{noSeperator}" p.PathWithinPackage : (Rid * Tfm * string) option) - |> Option.map (fun (rid, l, _) -> { Path = l; File = p; Runtime = rid })) + |> Option.map (fun (rid, l, _) -> { Path = l; File = p; Runtime = Some rid })) |> Option.orElseWith (fun _ -> (trySscanf "lib/%A{noSeperator}" p.PathWithinPackage : string option) - |> Option.map (fun (_) -> { Path = Tfm.Empty; File = p; Runtime = Rid.Any })) + |> Option.map (fun (_) -> { Path = Tfm.Empty; File = p; Runtime = None })) let getCompileLibAssembly (p:UnparsedPackageFile) = // %s because 'native' uses subfolders... @@ -354,26 +362,26 @@ module InstallModel = if path.Contains "/release/" then Release else if path.Contains "/debug/" then Debug else NoBuildMode - { Path = { l with Platforms = [ FrameworkIdentifier.Native(newBuildMode,newPlatform) ]}; File = p; Runtime = Rid.Any } + { Path = { l with Platforms = [ FrameworkIdentifier.Native(newBuildMode,newPlatform) ]}; File = p; Runtime = None } else - { Path = l; File = p; Runtime = Rid.Any }) + { Path = l; File = p; Runtime = None }) |> Option.orElseWith (fun _ -> (trySscanf "lib/%A{noSeperator}" p.PathWithinPackage : string option) - |> Option.map (fun (_) -> { Path = Tfm.Empty; File = p; Runtime = Rid.Any })) + |> Option.map (fun (_) -> { Path = Tfm.Empty; File = p; Runtime = None })) let getRuntimeLibrary (p:UnparsedPackageFile) = (trySscanf "runtimes/%A{rid}/nativeassets/%A{tfm}/%A{noSeperator}" p.PathWithinPackage : (Rid * Tfm * string) option) - |> Option.map (fun (rid, l,_) -> { Path = l; File = p; Runtime = rid }) + |> Option.map (fun (rid, l,_) -> { Path = l; File = p; Runtime = Some rid }) |> Option.orElseWith (fun _ -> (trySscanf "runtimes/%A{rid}/native/%A{noSeperator}" p.PathWithinPackage : (Rid * string) option) - |> Option.map (fun (rid, _) -> { Path = Tfm.Empty; File = p; Runtime = rid })) + |> Option.map (fun (rid, _) -> { Path = Tfm.Empty; File = p; Runtime = Some rid })) let getMsbuildFile (p:UnparsedPackageFile) = (trySscanf "build/%A{tfm}/%A{noSeperator}" p.PathWithinPackage : (Tfm * string) option) - |> Option.map (fun (l,_) -> { Path = l; File = p; Runtime = Rid.Any }) + |> Option.map (fun (l,_) -> { Path = l; File = p; Runtime = None }) |> Option.orElseWith (fun _ -> (trySscanf "build/%A{noSeperator}" p.PathWithinPackage : string option) - |> Option.map (fun (_) -> { Path = Tfm.Empty; File = p; Runtime = Rid.Any })) + |> Option.map (fun (_) -> { Path = Tfm.Empty; File = p; Runtime = None })) //let mapFolders mapfn (installModel:InstallModel) = // { installModel with @@ -391,6 +399,11 @@ module InstallModel = | Some folder -> choosefn folder.FolderContents | None -> Seq.empty + let private getFileFoldersByPath (path:Tfm) (folderType:seq>) choosefn = + match Seq.tryFind (fun (lib:FrameworkFolder<_>) -> path = lib.Path) folderType with + | Some folder -> choosefn folder.FolderContents + | None -> Seq.empty + let private getAllFiles folderType choosefn = folderType |> Seq.map (fun folder -> choosefn folder.FolderContents) @@ -422,16 +435,6 @@ module InstallModel = getLegacyReferences target installModel else results - let getRuntimeAssemblies (graph:RuntimeGraph) (rid:Rid) (target : TargetProfile) (installModel:InstallModel) = - getFileFolders target (installModel.RuntimeAssemblyFolders) (fun f -> f |> Set.toSeq) - |> Seq.cache - - let getRuntimeLibraries (graph:RuntimeGraph) (rid:Rid) (installModel:InstallModel) = - Seq.empty - // TODO: todo - //getFileFolders target (installModel.RuntimeAssemblyFolders) (fun f -> f |> Set.toSeq) - //|> Seq.cache - let getTargetsFiles (target : TargetProfile) (installModel:InstallModel) = getFileFolders target installModel.TargetsFileFolders (fun f -> f |> Set.toSeq) @@ -439,7 +442,7 @@ module InstallModel = let getLegacyPlatformReferences frameworkIdentifier installModel = getLegacyReferences (SinglePlatform frameworkIdentifier) installModel - let isEmpty (lib: LibFolder> list) = + let isEmpty (lib: FrameworkFolder> list) = lib |> Seq.map (fun l -> l.FolderContents) |> Seq.forall Set.isEmpty @@ -468,15 +471,16 @@ module InstallModel = let calcLegacyReferenceLibFolders = calcLibFoldersG ReferenceOrLibraryFolder.empty getCompileLibAssembly let calcReferenceFolders = calcLibFoldersG Set.empty getCompileRefAssembly let calcRuntimeAssemblyFolders = calcLibFoldersG Set.empty getRuntimeAssembly + let calcRuntimeLibraryFolders l = calcLibFoldersG Set.empty getRuntimeLibrary l //let calcRefFolders = calcLibFoldersG extractRefFolder - let addFileToFolder<'T, 'Item> (path:LibFolder<'T>) (file:'Item) (folders:LibFolder<'T> list) (addfn: 'Item -> 'T -> 'T) = + let addFileToFolder<'T, 'Item> (path:FrameworkFolder<'T>) (file:'Item) (folders:FrameworkFolder<'T> list) (addfn: 'Item -> 'T -> 'T) = folders |> List.map (fun p -> if p.Path <> path.Path then p else { p with FolderContents = addfn file p.FolderContents }) - let private addPackageLegacyLibFile references (path:LibFolder) (file:FrameworkDependentFile) (this:InstallModel) : InstallModel = + let private addPackageLegacyLibFile references (path:FrameworkFolder) (file:FrameworkDependentFile) (this:InstallModel) : InstallModel = let install = match references with | NuspecReferences.All -> true @@ -485,7 +489,7 @@ module InstallModel = { this with CompileLibFolders = addFileToFolder path (Library.ofFile file) this.CompileLibFolders ReferenceOrLibraryFolder.addLibrary } - let private addPackageRefFile references (path:LibFolder) (file:FrameworkDependentFile) (this:InstallModel) : InstallModel = + let private addPackageRefFile references (path:FrameworkFolder) (file:FrameworkDependentFile) (this:InstallModel) : InstallModel = let install = match references with | NuspecReferences.All -> true @@ -495,7 +499,7 @@ module InstallModel = { this with CompileRefFolders = addFileToFolder path (Library.ofFile file) this.CompileRefFolders Set.add } - let private addPackageRuntimeAssemblyFile references (path:LibFolder) (file:FrameworkDependentFile) (this:InstallModel) : InstallModel = + let private addPackageRuntimeAssemblyFile references (path:FrameworkFolder) (file:FrameworkDependentFile) (this:InstallModel) : InstallModel = let install = match references with | NuspecReferences.All -> true @@ -503,13 +507,23 @@ module InstallModel = if not install then this else { this with - RuntimeAssemblyFolders = addFileToFolder path (Library.ofFile file) this.RuntimeAssemblyFolders Set.add } + RuntimeAssemblyFolders = addFileToFolder path (RuntimeLibrary.ofFile file) this.RuntimeAssemblyFolders Set.add } + + let private addPackageRuntimeLibraryFile references (path:FrameworkFolder) (file:FrameworkDependentFile) (this:InstallModel) : InstallModel = + let install = + match references with + | NuspecReferences.All -> true + | NuspecReferences.Explicit list -> List.exists file.File.FullPath.EndsWith list + + if not install then this else + { this with + RuntimeLibFolders = addFileToFolder path (RuntimeLibrary.ofFile file) this.RuntimeLibFolders Set.add } let private addItem libs extract addFunc getFolder initialState = List.fold (fun (model:InstallModel) file -> match extract file with | Some (parsedFile:FrameworkDependentFile) -> - match List.tryFind (fun (folder:LibFolder<_>) -> folder.Path = parsedFile.Path) (getFolder model) with + match List.tryFind (fun (folder:FrameworkFolder<_>) -> folder.Path = parsedFile.Path) (getFolder model) with | Some path -> addFunc path parsedFile model | _ -> model | None -> model) initialState libs @@ -519,16 +533,19 @@ module InstallModel = let legacyLibFolders = calcLegacyReferenceLibFolders libs let refFolders = calcReferenceFolders libs let runtimeAssemblyFolders = calcRuntimeAssemblyFolders libs + let runtimeLibraryFolders = calcRuntimeLibraryFolders libs { installModel with CompileLibFolders = legacyLibFolders CompileRefFolders = refFolders - RuntimeAssemblyFolders = runtimeAssemblyFolders } + RuntimeAssemblyFolders = runtimeAssemblyFolders + RuntimeLibFolders = runtimeLibraryFolders } |> addItem libs getCompileLibAssembly (addPackageLegacyLibFile references) (fun i -> i.CompileLibFolders) |> addItem libs getCompileRefAssembly (addPackageRefFile references) (fun i -> i.CompileRefFolders) |> addItem libs getRuntimeAssembly (addPackageRuntimeAssemblyFile references) (fun i -> i.RuntimeAssemblyFolders) + |> addItem libs getRuntimeLibrary (addPackageRuntimeLibraryFile references) (fun i -> i.RuntimeLibFolders) - let addAnalyzerFiles (analyzerFiles:UnparsedPackageFile seq) (installModel:InstallModel) : InstallModel = + let addAnalyzerFiles (analyzerFiles:NuGet.UnparsedPackageFile seq) (installModel:InstallModel) : InstallModel = let analyzerLibs = analyzerFiles |> Seq.map (fun file -> FileInfo file.FullPath |> AnalyzerLib.FromFile) @@ -537,11 +554,71 @@ module InstallModel = { installModel with Analyzers = installModel.Analyzers @ analyzerLibs} - let rec addTargetsFile (path:LibFolder<_>) (file:FrameworkDependentFile) (installModel:InstallModel) :InstallModel = + let rec addTargetsFile (path:FrameworkFolder<_>) (file:FrameworkDependentFile) (installModel:InstallModel) :InstallModel = { installModel with TargetsFileFolders = addFileToFolder path (MsBuildFile.ofFile file) installModel.TargetsFileFolders Set.add } + let getAllRuntimeAssemblies (installModel:InstallModel) = + getAllFiles installModel.RuntimeAssemblyFolders (fun f -> f |> Set.toSeq) + |> Seq.cache + + let getRuntimeAssemblies (graph:RuntimeGraph) (rid:Rid) (target : TargetProfile) (installModel:InstallModel) = + // We need to recalculate the framework association after filtering with the RID + let allAssemblies = installModel.RuntimeAssemblyFolders |> Seq.collect (fun f -> f.FolderContents |> Seq.map (fun c -> f.Path, c)) + let allRids = allAssemblies |> Seq.choose (fun (_,s) -> s.Rid) |> Set.ofSeq + let bestMatchingRid = + RuntimeGraph.getInheritanceList rid graph + |> Seq.tryFind (fun rid -> allRids.Contains rid) + let filtered = allAssemblies |> Seq.filter (fun (_, a) -> a.Rid = None || a.Rid = bestMatchingRid) |> Seq.cache + let unParsedList = filtered |> Seq.map (fun (p, f) -> + { UnparsedPackageFile.FullPath = f.Library.Path; UnparsedPackageFile.PathWithinPackage = f.Library.PathWithinPackage } ) |> Seq.toList + let recalculated = calcRuntimeAssemblyFolders unParsedList + let filledFolder = + unParsedList + |> Seq.fold (fun folder (file) -> + let fdf = (getRuntimeAssembly file).Value + match List.tryFind (fun (folder:FrameworkFolder<_>) -> folder.Path = fdf.Path) (folder) with + | Some path -> addFileToFolder path (RuntimeLibrary.ofFile fdf) folder Set.add + | _ -> folder) recalculated + + let tfmData = + getFileFolders target filledFolder (Set.toSeq) + |> Seq.filter (fun lib -> lib.Rid = None || lib.Rid = bestMatchingRid) + |> Seq.cache + //if allRids.Count > 0 && bestMatchingRid = None then + // // No idea what this means, if this fails for you make this a warning or remove it completely. + // // I added this to see if it appears in the real world... + // failwithf "We found RID dependent assemblies in the package but nothing matched against '%A'" rid + tfmData + + let getAllRuntimeLibraries (installModel:InstallModel) = + getAllFiles installModel.RuntimeLibFolders (fun f -> f |> Set.toSeq) + |> Seq.cache + + let getRuntimeLibraries (graph:RuntimeGraph) (rid:Rid) (target : TargetProfile) (installModel:InstallModel) = + let allLibraries = getAllRuntimeLibraries installModel + if allLibraries |> Seq.exists (fun r -> r.Rid.IsNone) then + failwithf "Expected that all runtime libraries are associated with an RID." + let allRids = allLibraries |> Seq.choose (fun s -> s.Rid) |> Set.ofSeq + let bestMatchingRid = + RuntimeGraph.getInheritanceList rid graph + |> Seq.tryFind (fun rid -> allRids.Contains rid) + let tfmData = + getFileFolders target (installModel.RuntimeLibFolders) (Set.toSeq) + |> Seq.filter (fun lib -> lib.Rid = bestMatchingRid) + |> Seq.cache + let ridData = + getFileFoldersByPath Tfm.Empty installModel.RuntimeLibFolders Set.toSeq + |> Seq.filter (fun lib -> lib.Rid = bestMatchingRid) + |> Seq.cache + if allRids.Count > 0 && bestMatchingRid = None then + // No idea what this means, if this fails for you make this a warning or remove it completely. + // I added this to see if it appears in the real world... + failwithf "We found RID dependeny assemblies in the package but nothing matched against '%A'" rid + Seq.append tfmData ridData + + let mapFolderContents<'T> (mapfn: 'T -> 'T) folders = folders |> List.map (fun p -> @@ -561,18 +638,18 @@ module InstallModel = TargetsFileFolders = List.map mapfn installModel.TargetsFileFolders } let mapCompileLibFrameworkReferences mapfn (installModel:InstallModel) = - mapCompileLibFolders (LibFolder.map (fun l -> { l with FrameworkReferences = mapfn l.FrameworkReferences })) installModel + mapCompileLibFolders (FrameworkFolder.map (fun l -> { l with FrameworkReferences = mapfn l.FrameworkReferences })) installModel let mapCompileLibReferences mapfn (installModel:InstallModel) = - mapCompileLibFolders (LibFolder.map (fun l -> { l with Libraries = mapfn l.Libraries })) installModel + mapCompileLibFolders (FrameworkFolder.map (fun l -> { l with Libraries = mapfn l.Libraries })) installModel let mapCompileRefFiles mapfn (installModel:InstallModel) = - mapCompileRefFolders (LibFolder.map (mapfn)) installModel + mapCompileRefFolders (FrameworkFolder.map (mapfn)) installModel let mapRuntimeAssemblyFiles mapfn (installModel:InstallModel) = - mapRuntimeAssemblyFolders (LibFolder.map (mapfn)) installModel + mapRuntimeAssemblyFolders (FrameworkFolder.map (mapfn)) installModel let mapTargetsFiles mapfn (installModel:InstallModel) = - mapTargetsFileFolders (LibFolder.map (mapfn)) installModel + mapTargetsFileFolders (FrameworkFolder.map (mapfn)) installModel let addFrameworkAssemblyReference (installModel:InstallModel) (reference:FrameworkAssemblyReference) : InstallModel = - let referenceApplies (folder : LibFolder<_>) = + let referenceApplies (folder : FrameworkFolder<_>) = match reference.FrameworkRestrictions |> getRestrictionList with | [] -> true | restrictions -> @@ -605,7 +682,7 @@ module InstallModel = model |> mapCompileLibFolders(fun folder -> if referenceApplies folder then - LibFolder.map (fun c -> { c with FrameworkReferences = Set.add (FrameworkReference.ofName reference.AssemblyName) c.FrameworkReferences }) folder + FrameworkFolder.map (fun c -> { c with FrameworkReferences = Set.add (FrameworkReference.ofName reference.AssemblyName) c.FrameworkReferences }) folder //{ folder with FolderContents = { folder.FolderContents with FrameworkReferences = Set.add reference.AssemblyName folder.FolderContents.FrameworkReferences } } else folder) @@ -616,13 +693,13 @@ module InstallModel = let filterExcludes (excludes:string list) (installModel:InstallModel) = - let excluded e (reference:string) = - reference.Contains e + let excluded e (pathOrName:string) = + pathOrName.Contains e excludes |> List.fold (fun (model:InstallModel) fileName -> model - |> mapCompileLibReferences (Set.filter (fun n -> n.Name |> excluded fileName |> not)) + |> mapCompileLibReferences (Set.filter (fun n -> n.PathWithinPackage |> excluded fileName |> not)) |> mapCompileLibFrameworkReferences (Set.filter (fun r -> r.Name |> excluded fileName |> not)) ) installModel @@ -712,7 +789,7 @@ type InstallModel with member this.GetLegacyReferences target = InstallModel.getLegacyReferences target this member this.GetCompileReferences target = InstallModel.getCompileReferences target this member this.GetRuntimeAssemblies graph rid target = InstallModel.getRuntimeAssemblies graph rid target this - member this.GetRuntimeLibraries graph rid = InstallModel.getRuntimeLibraries graph rid this + member this.GetRuntimeLibraries graph rid target = InstallModel.getRuntimeLibraries graph rid target this [] member this.GetLibReferences frameworkIdentifier = InstallModel.getLegacyPlatformReferences frameworkIdentifier this diff --git a/src/Paket/Paket.fsproj b/src/Paket/Paket.fsproj index ea3424c65f..1fadd25137 100644 --- a/src/Paket/Paket.fsproj +++ b/src/Paket/Paket.fsproj @@ -37,8 +37,8 @@ D:\temp\coreclrtest install C:\dev\src\Paket\integrationtests\scenarios\loading-scripts\dependencies-file-flag\temp - update - C:\PROJ\Paket\integrationtests\scenarios\i001494-download\temp + install + C:\PROJ\Paket\integrationtests\scenarios\i001145-excludes\temp pdbonly diff --git a/tests/Paket.Tests/InstallModel/ProcessingSpecs.fs b/tests/Paket.Tests/InstallModel/ProcessingSpecs.fs index 9b07a9adc8..a19cbf5f1c 100644 --- a/tests/Paket.Tests/InstallModel/ProcessingSpecs.fs +++ b/tests/Paket.Tests/InstallModel/ProcessingSpecs.fs @@ -44,11 +44,12 @@ let ``should understand lib in lib.dll``() = model.GetLibReferences(SinglePlatform (DotNetFramework FrameworkVersion.V4_Client)) |> Seq.map (fun f -> f.Path) |> shouldContain @"..\FunScript.TypeScript\lib\net40\FunScript.TypeScript.Binding.lib.dll" -//[] -//let ``should understand libuv in runtimes``() = -// let model = emptymodel.AddReferences ([ @"..\Microsoft.AspNetCore.Server.Kestrel\runtimes\win7-x64\native\libuv.dll" ] |> fromLegacyList @"..\Microsoft.AspNetCore.Server.Kestrel\") -// -// model.GetLibReferences(SinglePlatform (Runtimes("win7-x64"))) |> shouldContain @"..\Microsoft.AspNetCore.Server.Kestrel\runtimes\win7-x64\native\libuv.dll" +[] +let ``should understand libuv in runtimes``() = + let model = emptymodel.AddReferences ([ @"..\Microsoft.AspNetCore.Server.Kestrel\runtimes\win7-x64\native\libuv.dll" ] |> fromLegacyList @"..\Microsoft.AspNetCore.Server.Kestrel\") + + model.GetRuntimeLibraries RuntimeGraph.Empty (Rid.Of "win7-x64") (SinglePlatform (DotNetFramework FrameworkVersion.V4_Client)) + |> Seq.map (fun (r:RuntimeLibrary) -> r.Library.Path) |> shouldContain @"..\Microsoft.AspNetCore.Server.Kestrel\runtimes\win7-x64\native\libuv.dll" [] let ``should understand reference folder``() = @@ -135,28 +136,35 @@ let ``should understand reference folder``() = refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\lib\netstandard1.6\System.Security.Cryptography.Algorithms.dll" refs |> shouldContain @"..\System.Security.Cryptography.Algorithms\ref\netstandard1.6\System.Security.Cryptography.Algorithms.dll" - // TODO: - //let refs = - // model.GetRuntimeAssemblies RuntimeGraph.Empty null (SinglePlatform (DotNetStandard DotNetStandardVersion.V1_6)) - // |> Seq.map (fun f -> f.Path) - //refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\runtimes\win\lib\net46\System.Security.Cryptography.Algorithms.dll" - //refs |> shouldContain @"..\System.Security.Cryptography.Algorithms\lib\netstandard1.6\System.Security.Cryptography.Algorithms.dll" - //refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\ref\netstandard1.6\System.Security.Cryptography.Algorithms.dll" - // - //let refs = - // model.GetRuntimeAssemblies null null(SinglePlatform (DotNetFramework FrameworkVersion.V4_6_3)) - // |> Seq.map (fun f -> f.Path) - //refs |> shouldContain @"..\System.Security.Cryptography.Algorithms\runtimes\win\lib\net46\System.Security.Cryptography.Algorithms.dll" - //// TODO: This is kind of broken for now -> the correct results depends on the runtime we want to get the runtime libraries for - //// therefore GetRuntimeLibraries needs an additional parameter... - //refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\lib\netstandard1.6\System.Security.Cryptography.Algorithms.dll" - //refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\ref\netstandard1.6\System.Security.Cryptography.Algorithms.dll" - -//[] -//let ``should understand aot in runtimes``() = -// let model = emptymodel.AddReferences ([ @"..\packages\System.Diagnostics.Contracts\runtimes\aot\lib\netcore50\System.Diagnostics.Contracts.dll" ] |> fromLegacyList @"..\packages\System.Diagnostics.Contracts\") -// -// model.GetLibReferences(SinglePlatform (Runtimes("aot"))) |> shouldContain @"..\packages\System.Diagnostics.Contracts\runtimes\aot\lib\netcore50\System.Diagnostics.Contracts.dll" + let refs = + model.GetRuntimeAssemblies RuntimeGraph.Empty (Rid.Of "win") (SinglePlatform (DotNetStandard DotNetStandardVersion.V1_6)) + |> Seq.map (fun f -> f.Library.Path) + refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\runtimes\win\lib\net46\System.Security.Cryptography.Algorithms.dll" + refs |> shouldContain @"..\System.Security.Cryptography.Algorithms\lib\netstandard1.6\System.Security.Cryptography.Algorithms.dll" + refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\ref\netstandard1.6\System.Security.Cryptography.Algorithms.dll" + + let refs = + model.GetRuntimeAssemblies RuntimeGraph.Empty (Rid.Of "win") (SinglePlatform (DotNetFramework FrameworkVersion.V4_6_3)) + |> Seq.map (fun f -> f.Library.Path) + refs |> shouldContain @"..\System.Security.Cryptography.Algorithms\runtimes\win\lib\net46\System.Security.Cryptography.Algorithms.dll" + refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\lib\netstandard1.6\System.Security.Cryptography.Algorithms.dll" + refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\ref\netstandard1.6\System.Security.Cryptography.Algorithms.dll" + + let refs = + model.GetRuntimeAssemblies RuntimeGraph.Empty (Rid.Of "unix") (SinglePlatform (DotNetFramework FrameworkVersion.V4_6_3)) + |> Seq.map (fun f -> f.Library.Path) + refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\runtimes\win\lib\net46\System.Security.Cryptography.Algorithms.dll" + refs |> shouldContain @"..\System.Security.Cryptography.Algorithms\lib\netstandard1.6\System.Security.Cryptography.Algorithms.dll" + refs |> shouldNotContain @"..\System.Security.Cryptography.Algorithms\ref\netstandard1.6\System.Security.Cryptography.Algorithms.dll" + +[] +let ``should understand aot in runtimes``() = + let model = emptymodel.AddReferences ([ @"..\packages\System.Diagnostics.Contracts\runtimes\aot\lib\netcore50\System.Diagnostics.Contracts.dll" ] |> fromLegacyList @"..\packages\System.Diagnostics.Contracts\") + + let refs = + model.GetRuntimeAssemblies RuntimeGraph.Empty (Rid.Of "aot") (SinglePlatform (DotNetCore DotNetCoreVersion.V1_0)) + |> Seq.map (fun f -> f.Library.Path) + refs |> shouldContain @"..\packages\System.Diagnostics.Contracts\runtimes\aot\lib\netcore50\System.Diagnostics.Contracts.dll" [] From 48515bd95dd92acf1d478ddeb158e7cae2a87008 Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Wed, 19 Apr 2017 12:42:32 +0200 Subject: [PATCH 27/30] cleanup and fixup of 'should understand aot in runtimes' test --- src/Paket.Core/Files/ProjectFile.fs | 15 +------ src/Paket.Core/FrameworkHandling.fs | 4 ++ src/Paket.Core/InstallModel.fs | 40 ++----------------- .../InstallModel/ProcessingSpecs.fs | 6 +-- 4 files changed, 11 insertions(+), 54 deletions(-) diff --git a/src/Paket.Core/Files/ProjectFile.fs b/src/Paket.Core/Files/ProjectFile.fs index f2739954ed..b90c044ddb 100644 --- a/src/Paket.Core/Files/ProjectFile.fs +++ b/src/Paket.Core/Files/ProjectFile.fs @@ -601,9 +601,7 @@ module ProjectFile = let getCustomModelNodes(model:InstallModel) (project:ProjectFile) = let libs : string Set = (model.GetAllLegacyReferenceAndFrameworkReferenceNames()) - //model.GetLibReferencesLazy.Force() - //|> Set.map (fun lib -> lib.ReferenceName) - + getCustomReferenceAndFrameworkNodes project |> List.filter (fun node -> let libName = node.Attributes.["Include"].InnerText.Split(',').[0] @@ -675,11 +673,6 @@ module ProjectFile = let createItemGroup (targets:TargetProfile list) (frameworkReferences:FrameworkReference list) (libraries:Library list) = let itemGroup = createNode "ItemGroup" project - //let refOrder (r:Reference) = - // match r with - // | Reference.FrameworkAssemblyReference _ -> 0 - // | Reference.Library _ -> 1 - // | _ -> 2 for ref in frameworkReferences |> List.sortBy (fun f -> f.Name) do createNode "Reference" project |> addAttribute "Include" ref.Name @@ -776,12 +769,6 @@ module ProjectFile = else let specialFrameworkAssemblies, rest = frameworkReferences |> List.partition (fun fr -> duplicates.Contains fr.Name) - //let frameworkAssemblies,rest = - // references - // |> List.partition (fun lib -> - // match lib with - // | Reference.FrameworkAssemblyReference frameworkAssembly -> duplicates.Contains lib - // | _ -> false) match PlatformMatching.getCondition referenceCondition allTargets !assemblyTargets with | "" -> [condition,createItemGroup libFolder.Targets rest libraries,false] diff --git a/src/Paket.Core/FrameworkHandling.fs b/src/Paket.Core/FrameworkHandling.fs index cfb14964af..f6f87ec2a6 100644 --- a/src/Paket.Core/FrameworkHandling.fs +++ b/src/Paket.Core/FrameworkHandling.fs @@ -666,6 +666,10 @@ module KnownTargetProfiles = let AllDotNetStandardProfiles = DotNetStandardProfiles @ DotNetCoreProfiles + // only used in "should understand aot in runtimes" test + // We don't support that anymore, if we add this here paket will create corresponding + // XML elements to compile for DNXCore... + //[SinglePlatform (DNXCore FrameworkVersion.V5_0)] let AllNativeProfiles = [ Native(NoBuildMode,NoPlatform) diff --git a/src/Paket.Core/InstallModel.fs b/src/Paket.Core/InstallModel.fs index 903c8374f9..f6bcacefe4 100644 --- a/src/Paket.Core/InstallModel.fs +++ b/src/Paket.Core/InstallModel.fs @@ -10,7 +10,6 @@ open ProviderImplementation.AssemblyReader.Utils.SHA1 type UnparsedPackageFile = Paket.NuGet.UnparsedPackageFile type Tfm = PlatformMatching.ParsedPlatformPath -//type Rid = Paket.Rid type FrameworkDependentFile = { Path : Tfm File : UnparsedPackageFile @@ -110,6 +109,8 @@ type InstallModel = Analyzers: AnalyzerLib list LicenseUrl: string option } +// TODO: This should move to its own module (maybe even a external library?) +// The tests below really should be unit tests... module FolderScanner = // Stolen and modifed to our needs from http://www.fssnip.net/4I/title/sscanf-parsing-with-format-strings open System.Text.RegularExpressions @@ -383,17 +384,6 @@ module InstallModel = (trySscanf "build/%A{noSeperator}" p.PathWithinPackage : string option) |> Option.map (fun (_) -> { Path = Tfm.Empty; File = p; Runtime = None })) - //let mapFolders mapfn (installModel:InstallModel) = - // { installModel with - // CompileLibFolders = List.map mapfn installModel.CompileLibFolders - // CompileRefFolders = List.map mapfn installModel.CompileRefFolders - // RuntimeLibFolders = List.map mapfn installModel.RuntimeLibFolders - // TargetsFileFolders = List.map mapfn installModel.TargetsFileFolders } - // - //let mapFiles mapfn (installModel:InstallModel) = - // installModel - // |> mapFolders (fun folder -> { folder with Files = mapfn folder.Files }) - let private getFileFolders (target:TargetProfile) folderType choosefn = match Seq.tryFind (fun lib -> Seq.exists ((=) target) lib.Targets) folderType with | Some folder -> choosefn folder.FolderContents @@ -472,7 +462,6 @@ module InstallModel = let calcReferenceFolders = calcLibFoldersG Set.empty getCompileRefAssembly let calcRuntimeAssemblyFolders = calcLibFoldersG Set.empty getRuntimeAssembly let calcRuntimeLibraryFolders l = calcLibFoldersG Set.empty getRuntimeLibrary l - //let calcRefFolders = calcLibFoldersG extractRefFolder let addFileToFolder<'T, 'Item> (path:FrameworkFolder<'T>) (file:'Item) (folders:FrameworkFolder<'T> list) (addfn: 'Item -> 'T -> 'T) = folders @@ -586,10 +575,7 @@ module InstallModel = getFileFolders target filledFolder (Set.toSeq) |> Seq.filter (fun lib -> lib.Rid = None || lib.Rid = bestMatchingRid) |> Seq.cache - //if allRids.Count > 0 && bestMatchingRid = None then - // // No idea what this means, if this fails for you make this a warning or remove it completely. - // // I added this to see if it appears in the real world... - // failwithf "We found RID dependent assemblies in the package but nothing matched against '%A'" rid + tfmData let getAllRuntimeLibraries (installModel:InstallModel) = @@ -683,7 +669,6 @@ module InstallModel = model |> mapCompileLibFolders(fun folder -> if referenceApplies folder then FrameworkFolder.map (fun c -> { c with FrameworkReferences = Set.add (FrameworkReference.ofName reference.AssemblyName) c.FrameworkReferences }) folder - //{ folder with FolderContents = { folder.FolderContents with FrameworkReferences = Set.add reference.AssemblyName folder.FolderContents.FrameworkReferences } } else folder) @@ -752,11 +737,6 @@ module InstallModel = this |> mapCompileLibReferences (Set.filter (fun reference -> Set.contains reference.Name references |> not)) |> mapCompileLibFrameworkReferences (Set.filter (fun reference -> Set.contains reference.Name references |> not)) - //let inline mapfn (files:InstallFiles) = - // { files with - // References = files.References |> Set.filter (fun reference -> Set.contains reference.ReferenceName references |> not) - // } - //mapFiles mapfn this let addLicense url (model: InstallModel) = if String.IsNullOrWhiteSpace url then model @@ -780,10 +760,6 @@ type InstallModel with [] member this.GetReferenceFolders() = InstallModel.getCompileLibFolders this - //member this.MapFolders mapfn = InstallModel.mapFolders mapfn this - - //member this.MapFiles mapfn = InstallModel.mapFiles mapfn this - [] member this.GetLibReferences target = InstallModel.getLegacyReferences target this member this.GetLegacyReferences target = InstallModel.getLegacyReferences target this @@ -802,16 +778,6 @@ type InstallModel with this.GetAllLegacyFrameworkReferences() |> Seq.map (fun r -> r.Name) |> Seq.append (this.GetAllLegacyReferences() |> Seq.map (fun r -> r.Name)) |> Set.ofSeq - //[] - //member this.GetFrameworkAssembliesLazy = InstallModel.getLegacyFrameworkAssembliesLazy this - //member this.GetLegacyFrameworkAssembliesLazy = InstallModel.getLegacyFrameworkAssembliesLazy this - - //[] - //member this.GetLibReferencesLazy = InstallModel.getLegacyReferencesLazy this - //member this.GetLegacyReferencesLazy = InstallModel.getLegacyReferencesLazy this - //member this.GetCompileReferencesLazy = InstallModel.getReferencesLazy this - // - //member this.GetTargetsFilesLazy = InstallModel.getTargetsFilesLazy this [] member this.CalcLibFolders libs = InstallModel.calcLegacyReferenceLibFolders libs diff --git a/tests/Paket.Tests/InstallModel/ProcessingSpecs.fs b/tests/Paket.Tests/InstallModel/ProcessingSpecs.fs index a19cbf5f1c..3763b98de3 100644 --- a/tests/Paket.Tests/InstallModel/ProcessingSpecs.fs +++ b/tests/Paket.Tests/InstallModel/ProcessingSpecs.fs @@ -159,12 +159,12 @@ let ``should understand reference folder``() = [] let ``should understand aot in runtimes``() = - let model = emptymodel.AddReferences ([ @"..\packages\System.Diagnostics.Contracts\runtimes\aot\lib\netcore50\System.Diagnostics.Contracts.dll" ] |> fromLegacyList @"..\packages\System.Diagnostics.Contracts\") + let model = emptymodel.AddReferences ([ @"..\packages\System.Diagnostics.Contracts\runtimes\aot\lib\netstandard13\System.Diagnostics.Contracts.dll" ] |> fromLegacyList @"..\packages\System.Diagnostics.Contracts\") let refs = - model.GetRuntimeAssemblies RuntimeGraph.Empty (Rid.Of "aot") (SinglePlatform (DotNetCore DotNetCoreVersion.V1_0)) + model.GetRuntimeAssemblies RuntimeGraph.Empty (Rid.Of "aot") (SinglePlatform (DotNetStandard DotNetStandardVersion.V1_6)) |> Seq.map (fun f -> f.Library.Path) - refs |> shouldContain @"..\packages\System.Diagnostics.Contracts\runtimes\aot\lib\netcore50\System.Diagnostics.Contracts.dll" + refs |> shouldContain @"..\packages\System.Diagnostics.Contracts\runtimes\aot\lib\netstandard13\System.Diagnostics.Contracts.dll" [] From 9743b2110e9282fe844dbcc7e7731df0cbd01b65 Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Wed, 19 Apr 2017 13:20:27 +0200 Subject: [PATCH 28/30] make two builds: one which fast publishes the package and one which runs the integration test suite --- appveyor.yml | 13 ++++++++++++- build.fsx | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 39c3336fde..32ec9a58bb 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,9 +13,20 @@ artifacts: nuget: account_feed: false project_feed: true + +environment: + # these variables are common to all jobs + #common_var1: value1 + + matrix: + # first group + - SkipIntegrationTests: true + # second group + - SkipNuGet: true + deploy: provider: NuGet - #server: # remove to push to NuGet.org + server: https://ci.appveyor.com/nuget/paket # remove to push to NuGet.org #api_key: # secure: m49OJ7+Jdt9an3jPcTukHA== #skip_symbols: false diff --git a/build.fsx b/build.fsx index 753a0dc435..13c01ff447 100644 --- a/build.fsx +++ b/build.fsx @@ -599,8 +599,8 @@ Target "All" DoNothing ==> "MergePaketTool" =?> ("MergePowerShell", not isMono) ==> "SignAssemblies" - ==> "NuGet" - =?> ("MergeDotnetCoreIntoNuget", not <| hasBuildParam "DISABLE_NETCORE") + =?> ("NuGet", not <| hasBuildParam "SkipNuGet") + =?> ("MergeDotnetCoreIntoNuget", not <| hasBuildParam "DISABLE_NETCORE" && not <| hasBuildParam "SkipNuGet") ==> "BuildPackage" "CleanDocs" From 347328194290956d43262bfb3ded92b9f4f7a020 Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Wed, 19 Apr 2017 13:39:39 +0200 Subject: [PATCH 29/30] tell appveyor that this are nuget packages. --- appveyor.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 32ec9a58bb..4ccb218cb2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -8,8 +8,8 @@ version: 0.0.1.{build} artifacts: - path: bin name: bin - - path: temp - name: nuget + - path: 'temp\*.nupkg' + type: NuGetPackage nuget: account_feed: false project_feed: true @@ -24,11 +24,11 @@ environment: # second group - SkipNuGet: true -deploy: - provider: NuGet - server: https://ci.appveyor.com/nuget/paket # remove to push to NuGet.org - #api_key: - # secure: m49OJ7+Jdt9an3jPcTukHA== - #skip_symbols: false - #symbol_server: # remove to push symbols to SymbolSource.org - artifact: /temp/.*\.nupkg/ +#deploy: +# provider: NuGet +# server: https://ci.appveyor.com/nuget/paket # remove to push to NuGet.org +# #api_key: +# # secure: m49OJ7+Jdt9an3jPcTukHA== +# #skip_symbols: false +# #symbol_server: # remove to push symbols to SymbolSource.org +# artifact: /temp/.*\.nupkg/ From 71673cedba705883a01c04bca14a25c19bffbb1f Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Wed, 19 Apr 2017 13:46:29 +0200 Subject: [PATCH 30/30] verbose is a bit too much --- build.fsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.fsx b/build.fsx index 13c01ff447..366a55a381 100644 --- a/build.fsx +++ b/build.fsx @@ -333,7 +333,7 @@ Target "MergePaketTool" (fun _ -> let result = ExecProcess (fun info -> info.FileName <- currentDirectory "packages" "build" "ILRepack" "tools" "ILRepack.exe" - info.Arguments <- sprintf "/verbose /lib:%s /ver:%s /out:%s %s" buildDir release.AssemblyVersion (buildMergedDir @@ "paket.exe") toPack + info.Arguments <- sprintf "/lib:%s /ver:%s /out:%s %s" buildDir release.AssemblyVersion (buildMergedDir @@ "paket.exe") toPack ) (TimeSpan.FromMinutes 5.) if result <> 0 then failwithf "Error during ILRepack execution."