From 5876ffaf26cc6a8a98a6b033f39fdc16dfe3ab82 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Tue, 7 Apr 2015 15:47:43 +0200 Subject: [PATCH 1/3] Basic TargetFrameworkSpecs --- src/Paket.Core/ProjectFile.fs | 16 ++++++++------- tests/Paket.Tests/Paket.Tests.fsproj | 3 ++- .../ProjectFile/TargetFrameworkSpecs.fs | 20 +++++++++++++++++++ 3 files changed, 31 insertions(+), 8 deletions(-) create mode 100644 tests/Paket.Tests/ProjectFile/TargetFrameworkSpecs.fs diff --git a/src/Paket.Core/ProjectFile.fs b/src/Paket.Core/ProjectFile.fs index b7a63fbd80..a7cf64519d 100644 --- a/src/Paket.Core/ProjectFile.fs +++ b/src/Paket.Core/ProjectFile.fs @@ -475,13 +475,15 @@ type ProjectFile = |> Seq.head member this.GetTargetFramework() = - seq {for outputType in this.Document |> getDescendants "TargetFrameworkVersion" -> - outputType.InnerText } - |> Seq.map (fun s -> // TODO make this a separate function - s.Replace("v","net") - |> FrameworkDetection.Extract) - |> Seq.map (fun o -> o.Value) - |> Seq.head + let framework = + seq {for outputType in this.Document |> getDescendants "TargetFrameworkVersion" -> + outputType.InnerText } + |> Seq.map (fun s -> // TODO make this a separate function + s.Replace("v","net") + |> FrameworkDetection.Extract) + |> Seq.map (fun o -> o.Value) + |> Seq.firstOrDefault + defaultArg framework (DotNetFramework(FrameworkVersion.V4)) member this.AddImportForPaketTargets(relativeTargetsPath) = match this.Document diff --git a/tests/Paket.Tests/Paket.Tests.fsproj b/tests/Paket.Tests/Paket.Tests.fsproj index 7c65f5bdeb..3b2557db02 100644 --- a/tests/Paket.Tests/Paket.Tests.fsproj +++ b/tests/Paket.Tests/Paket.Tests.fsproj @@ -1,4 +1,4 @@ - + @@ -222,6 +222,7 @@ Always + diff --git a/tests/Paket.Tests/ProjectFile/TargetFrameworkSpecs.fs b/tests/Paket.Tests/ProjectFile/TargetFrameworkSpecs.fs new file mode 100644 index 0000000000..84cc275937 --- /dev/null +++ b/tests/Paket.Tests/ProjectFile/TargetFrameworkSpecs.fs @@ -0,0 +1,20 @@ +module Paket.ProjectFile.TargetFrameworkSpecs + +open Paket +open NUnit.Framework +open FsUnit + +let element x = + match x with + | Some y -> y + | None -> failwith "not found" + +[] +let ``should detect TargetFramework in Project2 proj file``() = + ProjectFile.Load("./ProjectFile/TestData/Project2.fsprojtest").Value.GetTargetFramework().ToString() + |> shouldEqual "net40" + +[] +let ``should detect Pnet40 in empty proj file``() = + ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GetTargetFramework().ToString() + |> shouldEqual "net40" \ No newline at end of file From 4d320ec80e513c041cf63bedc8b17a0fa55936fd Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Tue, 7 Apr 2015 16:12:33 +0200 Subject: [PATCH 2/3] Detect Silverlight version in csproj files - fixes #751 --- RELEASE_NOTES.md | 3 + src/Paket.Core/FrameworkHandling.fs | 2 +- src/Paket.Core/ProjectFile.fs | 15 +++- .../InstallModel/FrameworkIdentifierSpecs.fs | 6 +- tests/Paket.Tests/Paket.Tests.fsproj | 3 + .../ProjectFile/TargetFrameworkSpecs.fs | 14 ++-- .../NewSilverlightClassLibrary.csprojtest | 78 +++++++++++++++++++ 7 files changed, 110 insertions(+), 11 deletions(-) create mode 100644 tests/Paket.Tests/ProjectFile/TestData/NewSilverlightClassLibrary.csprojtest diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 6595b206ad..cade123797 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,6 @@ +#### 0.38.5 - 07.04.2015 +* Detect Silverlight version in csproj files - https://github.com/fsprojects/Paket/issues/751 + #### 0.38.4 - 02.04.2015 * Fix mono timeout during license download - https://github.com/fsprojects/Paket/issues/746 diff --git a/src/Paket.Core/FrameworkHandling.fs b/src/Paket.Core/FrameworkHandling.fs index b54071edd0..7d6203b3c3 100644 --- a/src/Paket.Core/FrameworkHandling.fs +++ b/src/Paket.Core/FrameworkHandling.fs @@ -84,7 +84,7 @@ type FrameworkIdentifier = | Windows v -> "win" + v | WindowsPhoneApp v -> "wp" + v | WindowsPhoneSilverlight v -> "wp" + v - | Silverlight v -> "sl" + v + | Silverlight v -> "sl" + v.Replace("v","").Replace(".","") // returns a list of compatible platforms that this platform also supports diff --git a/src/Paket.Core/ProjectFile.fs b/src/Paket.Core/ProjectFile.fs index a7cf64519d..48d500143a 100644 --- a/src/Paket.Core/ProjectFile.fs +++ b/src/Paket.Core/ProjectFile.fs @@ -474,12 +474,23 @@ type ProjectFile = | _ -> ProjectOutputType.Library } |> Seq.head + member this.GetTargetFrameworkIdentifier() = + seq {for outputType in this.Document |> getDescendants "TargetFrameworkIdentifier" -> + outputType.InnerText } + |> Seq.firstOrDefault + member this.GetTargetFramework() = let framework = seq {for outputType in this.Document |> getDescendants "TargetFrameworkVersion" -> outputType.InnerText } - |> Seq.map (fun s -> // TODO make this a separate function - s.Replace("v","net") + |> Seq.map (fun s -> + // TODO make this a separate function + let prefix = + match this.GetTargetFrameworkIdentifier() with + | None -> "net" + | Some x -> x + + prefix + s.Replace("v","") |> FrameworkDetection.Extract) |> Seq.map (fun o -> o.Value) |> Seq.firstOrDefault diff --git a/tests/Paket.Tests/InstallModel/FrameworkIdentifierSpecs.fs b/tests/Paket.Tests/InstallModel/FrameworkIdentifierSpecs.fs index d9e77b10a6..49931a6dca 100644 --- a/tests/Paket.Tests/InstallModel/FrameworkIdentifierSpecs.fs +++ b/tests/Paket.Tests/InstallModel/FrameworkIdentifierSpecs.fs @@ -20,4 +20,8 @@ let ``should understand basic silverlight``() = let ``should serialize basic framework versions net20, net40, net45 ...``() = DotNetFramework(FrameworkVersion.V2).ToString() |> shouldEqual "net20" DotNetFramework(FrameworkVersion.V4_Client).ToString() |> shouldEqual "net40" - DotNetFramework(FrameworkVersion.V4_5).ToString() |> shouldEqual "net45" \ No newline at end of file + DotNetFramework(FrameworkVersion.V4_5).ToString() |> shouldEqual "net45" + +[] +let ``should serialize silverlight framework identifier correctly``() = + Silverlight("v5.0").ToString() |> shouldEqual "sl50" \ No newline at end of file diff --git a/tests/Paket.Tests/Paket.Tests.fsproj b/tests/Paket.Tests/Paket.Tests.fsproj index 3b2557db02..e437e2c56e 100644 --- a/tests/Paket.Tests/Paket.Tests.fsproj +++ b/tests/Paket.Tests/Paket.Tests.fsproj @@ -220,6 +220,9 @@ Always + + + Always diff --git a/tests/Paket.Tests/ProjectFile/TargetFrameworkSpecs.fs b/tests/Paket.Tests/ProjectFile/TargetFrameworkSpecs.fs index 84cc275937..a71395fc29 100644 --- a/tests/Paket.Tests/ProjectFile/TargetFrameworkSpecs.fs +++ b/tests/Paket.Tests/ProjectFile/TargetFrameworkSpecs.fs @@ -4,17 +4,17 @@ open Paket open NUnit.Framework open FsUnit -let element x = - match x with - | Some y -> y - | None -> failwith "not found" - [] let ``should detect TargetFramework in Project2 proj file``() = ProjectFile.Load("./ProjectFile/TestData/Project2.fsprojtest").Value.GetTargetFramework().ToString() |> shouldEqual "net40" [] -let ``should detect Pnet40 in empty proj file``() = +let ``should detect net40 in empty proj file``() = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GetTargetFramework().ToString() - |> shouldEqual "net40" \ No newline at end of file + |> shouldEqual "net40" + +[] +let ``should detect silverlight framework in new silverlight project2``() = + ProjectFile.Load("./ProjectFile/TestData/NewSilverlightClassLibrary.csprojtest").Value.GetTargetFramework() + |> shouldEqual (Silverlight("v5.0")) diff --git a/tests/Paket.Tests/ProjectFile/TestData/NewSilverlightClassLibrary.csprojtest b/tests/Paket.Tests/ProjectFile/TestData/NewSilverlightClassLibrary.csprojtest new file mode 100644 index 0000000000..4759a35d57 --- /dev/null +++ b/tests/Paket.Tests/ProjectFile/TestData/NewSilverlightClassLibrary.csprojtest @@ -0,0 +1,78 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {2DC62306-2201-4C2C-B1B7-C3284C3FCFEA} + {A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + SilverlightClassLibrary1 + SilverlightClassLibrary1 + Silverlight + v5.0 + $(TargetFrameworkVersion) + false + true + true + + + + v3.5 + + + true + full + false + Bin\Debug + DEBUG;TRACE;SILVERLIGHT + true + true + prompt + 4 + + + pdbonly + true + Bin\Release + TRACE;SILVERLIGHT + true + true + prompt + 4 + + + + + + + $(TargetFrameworkDirectory)System.Core.dll + + + + + + + + + + + + + + + + + + + \ No newline at end of file From a29d13c58759066c837943c5e30159c45efa2a5d Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Tue, 7 Apr 2015 16:14:51 +0200 Subject: [PATCH 3/3] Bump version to 0.38.5 --- src/Paket.Bootstrapper/Properties/AssemblyInfo.cs | 8 ++++---- src/Paket.Core/AssemblyInfo.fs | 8 ++++---- src/Paket/AssemblyInfo.fs | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Paket.Bootstrapper/Properties/AssemblyInfo.cs b/src/Paket.Bootstrapper/Properties/AssemblyInfo.cs index d1ed83f748..a5962ed87b 100644 --- a/src/Paket.Bootstrapper/Properties/AssemblyInfo.cs +++ b/src/Paket.Bootstrapper/Properties/AssemblyInfo.cs @@ -4,11 +4,11 @@ [assembly: AssemblyTitleAttribute("Paket.Bootstrapper")] [assembly: AssemblyProductAttribute("Paket")] [assembly: AssemblyDescriptionAttribute("A package dependency manager for .NET with support for NuGet packages and GitHub repositories.")] -[assembly: AssemblyVersionAttribute("0.38.4")] -[assembly: AssemblyFileVersionAttribute("0.38.4")] -[assembly: AssemblyInformationalVersionAttribute("0.38.4")] +[assembly: AssemblyVersionAttribute("0.38.5")] +[assembly: AssemblyFileVersionAttribute("0.38.5")] +[assembly: AssemblyInformationalVersionAttribute("0.38.5")] namespace System { internal static class AssemblyVersionInformation { - internal const string Version = "0.38.4"; + internal const string Version = "0.38.5"; } } diff --git a/src/Paket.Core/AssemblyInfo.fs b/src/Paket.Core/AssemblyInfo.fs index d86fd1e019..dcf8f0a5ca 100644 --- a/src/Paket.Core/AssemblyInfo.fs +++ b/src/Paket.Core/AssemblyInfo.fs @@ -5,10 +5,10 @@ open System.Reflection [] [] [] -[] -[] -[] +[] +[] +[] do () module internal AssemblyVersionInformation = - let [] Version = "0.38.4" + let [] Version = "0.38.5" diff --git a/src/Paket/AssemblyInfo.fs b/src/Paket/AssemblyInfo.fs index c5c71324ac..a95c6ee2f3 100644 --- a/src/Paket/AssemblyInfo.fs +++ b/src/Paket/AssemblyInfo.fs @@ -5,10 +5,10 @@ open System.Reflection [] [] [] -[] -[] -[] +[] +[] +[] do () module internal AssemblyVersionInformation = - let [] Version = "0.38.4" + let [] Version = "0.38.5"