Skip to content

Commit

Permalink
Merge pull request #879 from fsprojects/dnx
Browse files Browse the repository at this point in the history
Detection of DNX and DNXCore frameworks
  • Loading branch information
forki committed Jun 18, 2015
2 parents 55c0996 + 87c5ed9 commit 9b54a3e
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 19 deletions.
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#### 1.15.1 - 18.06.2015
* Detection of DNX and DNXCore frameworks

#### 1.15.0 - 18.06.2015
* Paket.PowerShell support for Paket Manager Console - https://github.com/fsprojects/Paket/pull/875
* Fix download of outdated files - https://github.com/fsprojects/Paket/issues/876
Expand Down
43 changes: 28 additions & 15 deletions src/Paket.Core/FrameworkHandling.fs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type FrameworkVersion =
| V4_5_2
| V4_5_3
| V4_6
| V5_0
override this.ToString() =
match this with
| V1 -> "v1.0"
Expand All @@ -32,6 +33,23 @@ type FrameworkVersion =
| V4_5_2 -> "v4.5.2"
| V4_5_3 -> "v4.5.3"
| V4_6 -> "v4.6"
| V5_0 -> "v5.0"

member this.ShortString() =
match this with
| FrameworkVersion.V1 -> "10"
| FrameworkVersion.V1_1 -> "11"
| FrameworkVersion.V2 -> "20"
| FrameworkVersion.V3 -> "30"
| FrameworkVersion.V3_5 -> "35"
| FrameworkVersion.V4_Client -> "40"
| FrameworkVersion.V4 -> "40"
| FrameworkVersion.V4_5 -> "45"
| FrameworkVersion.V4_5_1 -> "451"
| FrameworkVersion.V4_5_2 -> "452"
| FrameworkVersion.V4_5_3 -> "453"
| FrameworkVersion.V4_6 -> "46"
| FrameworkVersion.V5_0 -> "50"

module KnownAliases =
let Data =
Expand All @@ -52,6 +70,8 @@ module KnownAliases =
/// Framework Identifier type.
type FrameworkIdentifier =
| DotNetFramework of FrameworkVersion
| DNX of FrameworkVersion
| DNXCore of FrameworkVersion
| MonoAndroid
| MonoTouch
| MonoMac
Expand All @@ -63,21 +83,9 @@ type FrameworkIdentifier =

override x.ToString() =
match x with
| DotNetFramework v ->
"net" +
match v with
| FrameworkVersion.V1 -> "10"
| FrameworkVersion.V1_1 -> "11"
| FrameworkVersion.V2 -> "20"
| FrameworkVersion.V3 -> "30"
| FrameworkVersion.V3_5 -> "35"
| FrameworkVersion.V4_Client -> "40"
| FrameworkVersion.V4 -> "40"
| FrameworkVersion.V4_5 -> "45"
| FrameworkVersion.V4_5_1 -> "451"
| FrameworkVersion.V4_5_2 -> "452"
| FrameworkVersion.V4_5_3 -> "453"
| FrameworkVersion.V4_6 -> "46"
| DotNetFramework v -> "net" + v.ShortString()
| DNX v -> "dnx" + v.ShortString()
| DNXCore v -> "dnxcore" + v.ShortString()
| MonoAndroid -> "monoandroid"
| MonoTouch -> "monotouch"
| MonoMac -> "monomac"
Expand Down Expand Up @@ -105,6 +113,9 @@ type FrameworkIdentifier =
| DotNetFramework FrameworkVersion.V4_5_2 -> [ DotNetFramework FrameworkVersion.V4_5_1 ]
| DotNetFramework FrameworkVersion.V4_5_3 -> [ DotNetFramework FrameworkVersion.V4_5_2 ]
| DotNetFramework FrameworkVersion.V4_6 -> [ DotNetFramework FrameworkVersion.V4_5_3 ]
| DotNetFramework FrameworkVersion.V5_0 -> [ DotNetFramework FrameworkVersion.V4_6 ]
| DNX _ -> [ ]
| DNXCore _ -> [ ]
| Silverlight "v3.0" -> [ ]
| Silverlight "v4.0" -> [ Silverlight "v3.0" ]
| Silverlight "v5.0" -> [ Silverlight "v4.0" ]
Expand Down Expand Up @@ -161,6 +172,8 @@ module FrameworkDetection =
| "wp71" | "sl4-wp71" | "sl4-wp" -> Some (WindowsPhoneSilverlight "v7.1")
| "wp8" | "wp80" | "wpv80" -> Some (WindowsPhoneSilverlight "v8.0")
| "wpa00" | "wpa81" -> Some (WindowsPhoneApp "v8.1")
| "dnx451" -> Some(DNX FrameworkVersion.V4_5_1)
| "dnxcore50" -> Some(DNXCore FrameworkVersion.V5_0)
| _ -> None

cache.[path] <- result
Expand Down
2 changes: 2 additions & 0 deletions src/Paket.Core/PlatformMatching.fs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ let getTargetCondition (target:TargetProfile) =
| SinglePlatform(platform) ->
match platform with
| DotNetFramework(version) ->"$(TargetFrameworkIdentifier) == '.NETFramework'", sprintf "$(TargetFrameworkVersion) == '%O'" version
| DNX(version) ->"$(TargetFrameworkIdentifier) == 'DNX'", sprintf "$(TargetFrameworkVersion) == '%O'" version
| DNXCore(version) ->"$(TargetFrameworkIdentifier) == 'DNXCore'", sprintf "$(TargetFrameworkVersion) == '%O'" version
| Windows(version) -> "$(TargetFrameworkIdentifier) == '.NETCore'", sprintf "$(TargetFrameworkVersion) == '%O'" version
| Silverlight(version) -> "$(TargetFrameworkIdentifier) == 'Silverlight'", sprintf "$(TargetFrameworkVersion) == '%O'" version
| WindowsPhoneApp(version) -> "$(TargetFrameworkIdentifier) == 'WindowsPhoneApp'", sprintf "$(TargetFrameworkVersion) == '%O'" version
Expand Down
2 changes: 1 addition & 1 deletion src/Paket.Core/Requirements.fs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ let optimizeRestrictions packages =
[for restriction,packages in expanded do
match restriction with
| FrameworkRestriction.Exactly r ->
if r.ToString().StartsWith("net") then
if r.ToString().StartsWith("net") || r.ToString().StartsWith("dnx") then
yield r,packages |> Seq.map (fun (n,v,_) -> n,v) |> Seq.toList
| _ -> () ]
|> List.sortBy fst
Expand Down
5 changes: 2 additions & 3 deletions src/Paket/Paket.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@
<WarningLevel>3</WarningLevel>
<DocumentationFile>
</DocumentationFile>
<StartArguments>
</StartArguments>
<StartWorkingDirectory>D:\code\paket-866\tst</StartWorkingDirectory>
<StartArguments>update --hard -f</StartArguments>
<StartWorkingDirectory>D:\code\paket-dependencies</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup>
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
Expand Down
57 changes: 57 additions & 0 deletions tests/Paket.Tests/Nuspec/Microsoft.Framework.Logging.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>Microsoft.Framework.Logging</id>
<version>1.0.0-beta4</version>
<authors>Microsoft</authors>
<owners>Microsoft</owners>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<description>Logging infrastructure.</description>
<dependencies>
<group targetFramework=".NETFramework4.5">
<dependency id="Microsoft.Framework.DependencyInjection.Interfaces" version="1.0.0-beta4" />
<dependency id="Microsoft.Framework.Logging.Interfaces" version="1.0.0-beta4" />
</group>
<group targetFramework="DNX4.5.1">
<dependency id="Microsoft.Framework.DependencyInjection.Interfaces" version="1.0.0-beta4" />
<dependency id="Microsoft.Framework.Logging.Interfaces" version="1.0.0-beta4" />
</group>
<group targetFramework="DNXCore5.0">
<dependency id="Microsoft.Framework.DependencyInjection.Interfaces" version="1.0.0-beta4" />
<dependency id="Microsoft.Framework.Logging.Interfaces" version="1.0.0-beta4" />
<dependency id="System.Collections.Concurrent" version="4.0.10-beta-22816" />
<dependency id="System.Collections" version="4.0.10-beta-22816" />
<dependency id="System.Diagnostics.TraceSource" version="4.0.0-beta-22816" />
<dependency id="System.Globalization" version="4.0.10-beta-22816" />
<dependency id="System.Linq" version="4.0.0-beta-22816" />
<dependency id="System.Threading" version="4.0.10-beta-22816" />
</group>
<group targetFramework=".NETPortable4.6-Profile151">
<dependency id="Microsoft.Framework.DependencyInjection.Interfaces" version="1.0.0-beta4" />
<dependency id="Microsoft.Framework.Logging.Interfaces" version="1.0.0-beta4" />
</group>
</dependencies>
<frameworkAssemblies>
<frameworkAssembly assemblyName="System.Collections.Concurrent" targetFramework=".NETFramework4.5" />
<frameworkAssembly assemblyName="mscorlib" targetFramework=".NETFramework4.5" />
<frameworkAssembly assemblyName="System" targetFramework=".NETFramework4.5" />
<frameworkAssembly assemblyName="System.Core" targetFramework=".NETFramework4.5" />
<frameworkAssembly assemblyName="Microsoft.CSharp" targetFramework=".NETFramework4.5" />
<frameworkAssembly assemblyName="System.Collections.Concurrent" targetFramework="DNX4.5.1" />
<frameworkAssembly assemblyName="mscorlib" targetFramework="DNX4.5.1" />
<frameworkAssembly assemblyName="System" targetFramework="DNX4.5.1" />
<frameworkAssembly assemblyName="System.Core" targetFramework="DNX4.5.1" />
<frameworkAssembly assemblyName="Microsoft.CSharp" targetFramework="DNX4.5.1" />
<frameworkAssembly assemblyName="System.Collections" targetFramework=".NETPortable4.6-Profile151" />
<frameworkAssembly assemblyName="System.Collections.Concurrent" targetFramework=".NETPortable4.6-Profile151" />
<frameworkAssembly assemblyName="System.Reflection" targetFramework=".NETPortable4.6-Profile151" />
<frameworkAssembly assemblyName="System.Runtime.Extensions" targetFramework=".NETPortable4.6-Profile151" />
<frameworkAssembly assemblyName="System.Linq" targetFramework=".NETPortable4.6-Profile151" />
<frameworkAssembly assemblyName="System.Threading" targetFramework=".NETPortable4.6-Profile151" />
</frameworkAssemblies>
<licenseUrl>http://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm</licenseUrl>
<iconUrl>http://go.microsoft.com/fwlink/?LinkID=288859</iconUrl>
<copyright>Copyright © Microsoft Corporation</copyright>
<projectUrl>http://www.asp.net/</projectUrl>
</metadata>
</package>
17 changes: 17 additions & 0 deletions tests/Paket.Tests/Nuspec/NuspecSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,20 @@ let ``can detect explicit dependencies for WindowsAzure.Storage``() =
DependenciesFileParser.parseVersionRequirement(">= 5.0.8"),
[FrameworkRestriction.Exactly(WindowsPhoneSilverlight("v8.0"))
FrameworkRestriction.AtLeast(DotNetFramework(FrameworkVersion.V4_Client))])

[<Test>]
let ``can detect framework assemblies for Microsoft.Framework.Logging``() =
let nuspec = Nuspec.Load("Nuspec/Microsoft.Framework.Logging.nuspec")
nuspec.FrameworkAssemblyReferences.[0].AssemblyName |> shouldEqual "System.Collections.Concurrent"
nuspec.FrameworkAssemblyReferences.[0].FrameworkRestrictions
|> shouldEqual
[FrameworkRestriction.Exactly(DotNetFramework(FrameworkVersion.V4_5))
FrameworkRestriction.Exactly(DNX(FrameworkVersion.V4_5_1))]

let name,_,restrictions = nuspec.Dependencies.[0]
name |> shouldEqual (PackageName "Microsoft.Framework.DependencyInjection.Interfaces")
restrictions|> shouldEqual []

let name,_,restrictions = nuspec.Dependencies.[2]
name |> shouldEqual (PackageName "System.Collections.Concurrent")
restrictions |> shouldEqual [FrameworkRestriction.Exactly(DNXCore(FrameworkVersion.V5_0))]
3 changes: 3 additions & 0 deletions tests/Paket.Tests/Paket.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@
<Content Include="Nuspec\LiteGuard.Source.nuspec">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Nuspec\Microsoft.Framework.Logging.nuspec">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Compile Include="Nuspec\NuspecSpecs.fs" />
<Content Include="NuGetOData\Fantomas.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Expand Down

0 comments on commit 9b54a3e

Please sign in to comment.