Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for dotnet 8 #4219

Merged
merged 5 commits into from
Jul 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 98 additions & 8 deletions src/Paket.Core/Versioning/FrameworkHandling.fs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 127,24 @@ type Net7WindowsVersion =
| "10.0.19041.0" | "10.0.19041" -> Some Net7WindowsVersion.V10_0_19041_0
| _ -> None

[<RequireQualifiedAccess>]
type Net8WindowsVersion =
| V10_0_17763_0
| V10_0_18362_0
| V10_0_19041_0
override this.ToString() =
match this with
| V10_0_17763_0 -> "10.0.17763.0"
| V10_0_18362_0 -> "10.0.18362.0"
| V10_0_19041_0 -> "10.0.19041.0"

static member TryParse s =
match s with
| "" | "10.0.17763.0" | "10.0.17763" -> Some Net8WindowsVersion.V10_0_17763_0
| "10.0.18362.0" | "10.0.18362" -> Some Net8WindowsVersion.V10_0_18362_0
| "10.0.19041.0" | "10.0.19041" -> Some Net8WindowsVersion.V10_0_19041_0
| _ -> None

[<RequireQualifiedAccess>]
type Net5Os =
| Android
Expand Down Expand Up @@ -199,7 217,33 @@ type Net7Os =
("tvos",Net7Os.TvOs)
("watchos",Net7Os.WatchOs)
] |> Seq.tryFind(fun (k,_) -> s.StartsWith k)
|> Option.map snd
|> Option.map snd

[<RequireQualifiedAccess>]
type Net8Os =
| Android
| IOs
| MacOs
| TvOs
| WatchOs
override this.ToString() =
match this with
| Android -> "android"
| IOs -> "ios"
| MacOs -> "macos"
| TvOs -> "tvos"
| WatchOs -> "watchos"

static member TryParse (s:string) =
[
"android",Net8Os.Android
"ios" ,Net8Os.IOs
"macos" ,Net8Os.MacOs
"tvos" ,Net8Os.TvOs
"watchos",Net8Os.WatchOs
]
|> Seq.tryFind(fun (k,_) -> s.StartsWith k)
|> Option.map snd


[<RequireQualifiedAccess>]
Expand Down Expand Up @@ -228,6 272,7 @@ type FrameworkVersion =
| V5
| V6
| V7
| V8
override this.ToString() =
match this with
| V1 -> "v1.0"
Expand All @@ -252,6 297,7 @@ type FrameworkVersion =
| V5 -> "v5.0"
| V6 -> "v6.0"
| V7 -> "v7.0"
| V8 -> "v8.0"

member this.ShortString() =
match this with
Expand All @@ -277,6 323,7 @@ type FrameworkVersion =
| FrameworkVersion.V5 -> "5.0"
| FrameworkVersion.V6 -> "6.0"
| FrameworkVersion.V7 -> "7.0"
| FrameworkVersion.V8 -> "8.0"

static member TryParse s =
match s with
Expand All @@ -302,6 349,7 @@ type FrameworkVersion =
| "5" -> Some FrameworkVersion.V5
| "6" -> Some FrameworkVersion.V6
| "7" -> Some FrameworkVersion.V7
| "8" -> Some FrameworkVersion.V8
| _ -> None

[<RequireQualifiedAccess>]
Expand Down Expand Up @@ -737,6 785,8 @@ type FrameworkIdentifier =
| DotNet6Windows of Net6WindowsVersion
| DotNet7WithOs of Net7Os
| DotNet7Windows of Net7WindowsVersion
| DotNet8WithOs of Net8Os
| DotNet8Windows of Net8WindowsVersion
| DotNet5WithOs of Net5Os
| DotNet5Windows of Net5WindowsVersion
| UAP of UAPVersion
Expand All @@ -762,7 812,9 @@ type FrameworkIdentifier =
override x.ToString() =
match x with
| DotNetFramework v -> "net" v.ShortString()
| DotNet7WithOs o -> "net7.0-" o.ToString()
| DotNet8WithOs o -> "net8.0-" o.ToString()
| DotNet8Windows v -> "net8.0-windows" v.ToString()
| DotNet7WithOs o -> "net7.0-" o.ToString()
| DotNet7Windows v -> "net7.0-windows" v.ToString()
| DotNet6WithOs o -> "net6.0-" o.ToString()
| DotNet6Windows v -> "net6.0-windows" v.ToString()
Expand Down Expand Up @@ -870,6 922,7 @@ type FrameworkIdentifier =
| DotNetFramework FrameworkVersion.V5 -> [ DotNetCoreApp DotNetCoreAppVersion.V3_1; DotNetStandard DotNetStandardVersion.V2_1 ]
| DotNetFramework FrameworkVersion.V6 -> [ DotNetFramework FrameworkVersion.V5 ]
| DotNetFramework FrameworkVersion.V7 -> [ DotNetFramework FrameworkVersion.V6 ]
| DotNetFramework FrameworkVersion.V8 -> [ DotNetFramework FrameworkVersion.V7 ]
| DotNet5WithOs Net5Os.Android -> [ DotNetFramework FrameworkVersion.V5; MonoAndroid MonoAndroidVersion.V12 ]
| DotNet5WithOs Net5Os.IOs -> [ DotNetFramework FrameworkVersion.V5; XamariniOS ]
| DotNet5WithOs Net5Os.MacOs -> [ DotNetFramework FrameworkVersion.V5; XamarinMac ]
Expand All @@ -890,6 943,11 @@ type FrameworkIdentifier =
| DotNet7WithOs Net7Os.MacOs -> [ DotNetFramework FrameworkVersion.V7; XamarinMac ]
| DotNet7WithOs Net7Os.TvOs -> [ DotNetFramework FrameworkVersion.V7; XamarinTV ]
| DotNet7WithOs Net7Os.WatchOs -> [ DotNetFramework FrameworkVersion.V7; XamarinWatch ]
| DotNet8WithOs Net8Os.Android -> [ DotNetFramework FrameworkVersion.V8; MonoAndroid MonoAndroidVersion.V12 ]
| DotNet8WithOs Net8Os.IOs -> [ DotNetFramework FrameworkVersion.V8; XamariniOS ]
| DotNet8WithOs Net8Os.MacOs -> [ DotNetFramework FrameworkVersion.V8; XamarinMac ]
| DotNet8WithOs Net8Os.TvOs -> [ DotNetFramework FrameworkVersion.V8; XamarinTV ]
| DotNet8WithOs Net8Os.WatchOs -> [ DotNetFramework FrameworkVersion.V8; XamarinWatch ]
| DotNet6Windows Net6WindowsVersion.V7_0 -> [ DotNetFramework FrameworkVersion.V6 ]
| DotNet6Windows Net6WindowsVersion.V8_0 -> [ DotNetFramework FrameworkVersion.V6; DotNet6Windows Net6WindowsVersion.V7_0 ]
| DotNet6Windows Net6WindowsVersion.V10_0_17763_0 -> [ DotNetFramework FrameworkVersion.V6; DotNet6Windows Net6WindowsVersion.V8_0 ]
Expand All @@ -900,6 958,9 @@ type FrameworkIdentifier =
| DotNet7Windows Net7WindowsVersion.V10_0_17763_0 -> [ DotNetFramework FrameworkVersion.V7; DotNet7Windows Net7WindowsVersion.V8_0 ]
| DotNet7Windows Net7WindowsVersion.V10_0_18362_0 -> [ DotNetFramework FrameworkVersion.V7; DotNet7Windows Net7WindowsVersion.V10_0_17763_0 ]
| DotNet7Windows Net7WindowsVersion.V10_0_19041_0 -> [ DotNetFramework FrameworkVersion.V7; DotNet7Windows Net7WindowsVersion.V10_0_18362_0 ]
| DotNet8Windows Net8WindowsVersion.V10_0_17763_0 -> [ DotNetFramework FrameworkVersion.V8; ]
| DotNet8Windows Net8WindowsVersion.V10_0_18362_0 -> [ DotNetFramework FrameworkVersion.V8; DotNet8Windows Net8WindowsVersion.V10_0_17763_0 ]
| DotNet8Windows Net8WindowsVersion.V10_0_19041_0 -> [ DotNetFramework FrameworkVersion.V8; DotNet8Windows Net8WindowsVersion.V10_0_18362_0 ]
| DotNetStandard DotNetStandardVersion.V1_0 -> [ ]
| DotNetStandard DotNetStandardVersion.V1_1 -> [ DotNetStandard DotNetStandardVersion.V1_0 ]
| DotNetStandard DotNetStandardVersion.V1_2 -> [ DotNetStandard DotNetStandardVersion.V1_1 ]
Expand Down Expand Up @@ -1014,6 1075,7 @@ module FrameworkDetection =
| Some "5" when dotnetVersionX = 5 -> tryParseSecondPart parts.[1]
| Some "6" when dotnetVersionX = 6 -> tryParseSecondPart parts.[1]
| Some "7" when dotnetVersionX = 7 -> tryParseSecondPart parts.[1]
| Some "8" when dotnetVersionX = 8 -> tryParseSecondPart parts.[1]
| _ -> None
else
None
Expand All @@ -1027,6 1089,7 @@ module FrameworkDetection =
| Some "5" when dotnetVersionX = 5 -> tryParseVersion winVersionPart
| Some "6" when dotnetVersionX = 6 -> tryParseVersion winVersionPart
| Some "7" when dotnetVersionX = 7 -> tryParseVersion winVersionPart
| Some "8" when dotnetVersionX = 8 -> tryParseVersion winVersionPart
| _ -> None
else
None
Expand Down Expand Up @@ -1066,17 1129,19 @@ module FrameworkDetection =
// http://nugettoolsdev.azurewebsites.net/4.0.0/parse-framework?framework=.NETPortable,Version=v0.0,Profile=Profile2
let result =
match path with
| MatchNetXDashWindows 8 Net8WindowsVersion.TryParse fm -> Some (DotNet8Windows fm)
| MatchNetXDashWindows 7 Net7WindowsVersion.TryParse fm -> Some (DotNet7Windows fm)
| MatchNetXDashWindows 6 Net6WindowsVersion.TryParse fm -> Some (DotNet6Windows fm)
| MatchNetXDashWindows 5 Net5WindowsVersion.TryParse fm -> Some (DotNet5Windows fm)
| MatchNetXDashOs 8 Net8Os.TryParse fm -> Some (DotNet8WithOs fm)
| MatchNetXDashOs 7 Net7Os.TryParse fm -> Some (DotNet7WithOs fm)
| MatchNetXDashOs 6 Net6Os.TryParse fm -> Some (DotNet6WithOs fm)
| MatchNetXDashOs 5 Net5Os.TryParse fm -> Some (DotNet5WithOs fm)
| "netcoreapp5.0" -> Some (DotNetFramework FrameworkVersion.V5)
| "net35-Unity Web v3.5" -> Some (DotNetUnity DotNetUnityVersion.V3_5_Web)
| "net35-Unity Micro v3.5" -> Some (DotNetUnity DotNetUnityVersion.V3_5_Micro)
| "net35-Unity Subset v3.5" -> Some (DotNetUnity DotNetUnityVersion.V3_5_Subset)
| "net35-Unity Full v3.5" -> Some (DotNetUnity DotNetUnityVersion.V3_5_Full)
| MatchNetXDashWindows 5 Net5WindowsVersion.TryParse fm -> Some (DotNet5Windows fm)
| MatchNetXDashWindows 6 Net6WindowsVersion.TryParse fm -> Some (DotNet6Windows fm)
| MatchNetXDashWindows 7 Net7WindowsVersion.TryParse fm -> Some (DotNet7Windows fm)
| MatchNetXDashOs 5 Net5Os.TryParse fm -> Some (DotNet5WithOs fm)
| MatchNetXDashOs 6 Net6Os.TryParse fm -> Some (DotNet6WithOs fm)
| MatchNetXDashOs 7 Net7Os.TryParse fm -> Some (DotNet7WithOs fm)
| ModifyMatchTfm skipFullAndClient "net" FrameworkVersion.TryParse fm -> Some (DotNetFramework fm)
// Backwards compat quirk (2017-08-20).
| "uap101" -> Some (UAP UAPVersion.V10_1)
Expand Down Expand Up @@ -1450,6 1515,7 @@ module KnownTargetProfiles =
FrameworkVersion.V5
FrameworkVersion.V6
FrameworkVersion.V7
FrameworkVersion.V8
]

let DotNetFrameworkIdentifiers =
Expand Down Expand Up @@ -1532,6 1598,28 @@ module KnownTargetProfiles =
DotNet7WindowsVersions
|> List.map (DotNet7Windows >> TargetProfile.SinglePlatform)

let DotNet8OperatingSystems = [
Net8Os.Android
Net8Os.IOs
Net8Os.MacOs
Net8Os.TvOs
Net8Os.WatchOs
]

let DotNet8WithOsProfiles =
DotNet8OperatingSystems
|> List.map (DotNet8WithOs >> TargetProfile.SinglePlatform)

let DotNet8WindowsVersions = [
Net8WindowsVersion.V10_0_17763_0
Net8WindowsVersion.V10_0_18362_0
Net8WindowsVersion.V10_0_19041_0
]

let DotNet8WindowsProfiles =
DotNet8WindowsVersions
|> List.map (DotNet8Windows >> TargetProfile.SinglePlatform)

let DotNetStandardVersions = [
DotNetStandardVersion.V1_0
DotNetStandardVersion.V1_1
Expand Down Expand Up @@ -1703,6 1791,8 @@ module KnownTargetProfiles =

let AllDotNetProfiles =
DotNetFrameworkProfiles @
DotNet8WithOsProfiles @
DotNet8WindowsProfiles @
DotNet7WithOsProfiles @
DotNet7WindowsProfiles @
DotNet6WithOsProfiles @
Expand Down
3 changes: 3 additions & 0 deletions src/Paket.Core/Versioning/PlatformMatching.fs
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 213,13 @@ let getTargetCondition (target:TargetProfile) =
match target with
| TargetProfile.SinglePlatform(platform) ->
match platform with
| DotNetFramework(FrameworkVersion.V8) ->"$(TargetFrameworkIdentifier) == '.NETCoreApp'", "$(TargetFrameworkVersion) == 'v8.0'"
| DotNetFramework(FrameworkVersion.V7) ->"$(TargetFrameworkIdentifier) == '.NETCoreApp'", "$(TargetFrameworkVersion) == 'v7.0'"
| DotNetFramework(FrameworkVersion.V6) ->"$(TargetFrameworkIdentifier) == '.NETCoreApp'", "$(TargetFrameworkVersion) == 'v6.0'"
| DotNetFramework(FrameworkVersion.V5) ->"$(TargetFrameworkIdentifier) == '.NETCoreApp'", "$(TargetFrameworkVersion) == 'v5.0'"
| DotNetFramework(version) ->"$(TargetFrameworkIdentifier) == '.NETFramework'", sprintf "$(TargetFrameworkVersion) == '%O'" version
| DotNet8WithOs(os) ->"$(TargetFrameworkIdentifier) == '.NETCoreApp'", sprintf "($(TargetFrameworkVersion) == 'v7.0' And '$(TargetPlatformIdentifier)' == '%O')" os
| DotNet8Windows(version) ->"$(TargetFrameworkIdentifier) == '.NETCoreApp'", sprintf "($(TargetFrameworkVersion) == 'v7.0' And '$(TargetPlatformIdentifier)' == 'Windows' And '$(TargetPlatformVersion)' == '%O')" version
| DotNet7WithOs(os) ->"$(TargetFrameworkIdentifier) == '.NETCoreApp'", sprintf "($(TargetFrameworkVersion) == 'v7.0' And '$(TargetPlatformIdentifier)' == '%O')" os
| DotNet7Windows(Net7WindowsVersion.V7_0) ->"$(TargetFrameworkIdentifier) == '.NETCoreApp'", sprintf "($(TargetFrameworkVersion) == 'v7.0' And '$(TargetPlatformIdentifier)' == 'Windows')"
| DotNet7Windows(version) ->"$(TargetFrameworkIdentifier) == '.NETCoreApp'", sprintf "($(TargetFrameworkVersion) == 'v7.0' And '$(TargetPlatformIdentifier)' == 'Windows' And '$(TargetPlatformVersion)' == '%O')" version
Expand Down
15 changes: 15 additions & 0 deletions tests/Paket.Tests/DependenciesFile/ParserSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 1243,21 @@ let ``should read config with .NET 7 target framework``() =
|> getExplicitRestriction
|> shouldEqual (FrameworkRestriction.AtLeast(FrameworkIdentifier.DotNetFramework(FrameworkVersion.V7)))

let configNET8TargetFramework = """source https://www.nuget.org/api/v2

framework: >= net8.0

nuget System.Data.SQLite 1.0.98.1 content: none
"""

[<Test>]
let ``should read config with .NET 8 target framework``() =
let cfg = DependenciesFile.FromSource(configNET8TargetFramework)

cfg.Groups.[Constants.MainDependencyGroup].Options.Settings.FrameworkRestrictions
|> getExplicitRestriction
|> shouldEqual (FrameworkRestriction.AtLeast(FrameworkIdentifier.DotNetFramework(FrameworkVersion.V8)))

let validFrameworks =
let net40 = DotNetFramework(FrameworkVersion.V4)
let net45 = DotNetFramework(FrameworkVersion.V4_5)
Expand Down
Loading