Skip to content

Commit 7e23dcb

Browse files
initial adding of framework handling for dotnet 9.
1 parent 4954f9f commit 7e23dcb

File tree

4 files changed

+67
-4
lines changed

4 files changed

+67
-4
lines changed

src/Paket.Core/Versioning/FrameworkHandling.fs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ type Net8WindowsVersion =
151151
| "10.0.19041.0" | "10.0.19041" -> Some Net8WindowsVersion.V10_0_19041_0
152152
| _ -> None
153153

154+
type Net9WindowsVersion = Net8WindowsVersion
155+
154156
[<RequireQualifiedAccess>]
155157
type Net5Os =
156158
| Android
@@ -250,7 +252,8 @@ type Net8Os =
250252
]
251253
|> Seq.tryFind(fun (k,_) -> s.StartsWith k)
252254
|> Option.map snd
253-
255+
256+
type Net9Os = Net8Os
254257

255258
[<RequireQualifiedAccess>]
256259
/// The Framework version.
@@ -280,6 +283,7 @@ type FrameworkVersion =
280283
| V6
281284
| V7
282285
| V8
286+
| V9
283287
override this.ToString() =
284288
match this with
285289
| V1 -> "v1.0"
@@ -301,11 +305,12 @@ type FrameworkVersion =
301305
| V4_7_1 -> "v4.7.1"
302306
| V4_7_2 -> "v4.7.2"
303307
| V4_8 -> "v4.8"
304-
| V4_8_1 -> "v4.8.1"
308+
| V4_8_1 -> "v4.8.1"
305309
| V5 -> "v5.0"
306310
| V6 -> "v6.0"
307311
| V7 -> "v7.0"
308312
| V8 -> "v8.0"
313+
| V9 -> "v9.0"
309314

310315
member this.ShortString() =
311316
match this with
@@ -333,6 +338,7 @@ type FrameworkVersion =
333338
| FrameworkVersion.V6 -> "6.0"
334339
| FrameworkVersion.V7 -> "7.0"
335340
| FrameworkVersion.V8 -> "8.0"
341+
| FrameworkVersion.V9 -> "9.0"
336342

337343
static member TryParse s =
338344
match s with
@@ -360,6 +366,7 @@ type FrameworkVersion =
360366
| "6" -> Some FrameworkVersion.V6
361367
| "7" -> Some FrameworkVersion.V7
362368
| "8" -> Some FrameworkVersion.V8
369+
| "9" -> Some FrameworkVersion.V9
363370
| _ -> None
364371

365372
[<RequireQualifiedAccess>]
@@ -791,14 +798,16 @@ type TizenVersion =
791798
// Each time a new version is added NuGetPackageCache.CurrentCacheVersion should be bumped.
792799
type FrameworkIdentifier =
793800
| DotNetFramework of FrameworkVersion
801+
| DotNet5WithOs of Net5Os
802+
| DotNet5Windows of Net5WindowsVersion
794803
| DotNet6WithOs of Net6Os
795804
| DotNet6Windows of Net6WindowsVersion
796805
| DotNet7WithOs of Net7Os
797806
| DotNet7Windows of Net7WindowsVersion
798807
| DotNet8WithOs of Net8Os
799808
| DotNet8Windows of Net8WindowsVersion
800-
| DotNet5WithOs of Net5Os
801-
| DotNet5Windows of Net5WindowsVersion
809+
| DotNet9WithOs of Net9Os
810+
| DotNet9Windows of Net9WindowsVersion
802811
| UAP of UAPVersion
803812
| DotNetStandard of DotNetStandardVersion
804813
| DotNetCoreApp of DotNetCoreAppVersion
@@ -822,6 +831,8 @@ type FrameworkIdentifier =
822831
override x.ToString() =
823832
match x with
824833
| DotNetFramework v -> "net" + v.ShortString()
834+
| DotNet9WithOs o -> "net9.0-" + o.ToString()
835+
| DotNet9Windows v -> "net9.0-windows" + v.ToString()
825836
| DotNet8WithOs o -> "net8.0-" + o.ToString()
826837
| DotNet8Windows v -> "net8.0-windows" + v.ToString()
827838
| DotNet7WithOs o -> "net7.0-" + o.ToString()
@@ -934,6 +945,7 @@ type FrameworkIdentifier =
934945
| DotNetFramework FrameworkVersion.V6 -> [ DotNetFramework FrameworkVersion.V5 ]
935946
| DotNetFramework FrameworkVersion.V7 -> [ DotNetFramework FrameworkVersion.V6 ]
936947
| DotNetFramework FrameworkVersion.V8 -> [ DotNetFramework FrameworkVersion.V7 ]
948+
| DotNetFramework FrameworkVersion.V9 -> [ DotNetFramework FrameworkVersion.V8 ]
937949
| DotNet5WithOs Net5Os.Android -> [ DotNetFramework FrameworkVersion.V5; MonoAndroid MonoAndroidVersion.V12 ]
938950
| DotNet5WithOs Net5Os.IOs -> [ DotNetFramework FrameworkVersion.V5; XamariniOS ]
939951
| DotNet5WithOs Net5Os.MacOs -> [ DotNetFramework FrameworkVersion.V5; XamarinMac ]
@@ -974,6 +986,7 @@ type FrameworkIdentifier =
974986
| DotNet8Windows Net8WindowsVersion.V10_0_17763_0 -> [ DotNetFramework FrameworkVersion.V8; DotNet8Windows Net8WindowsVersion.V8_0]
975987
| DotNet8Windows Net8WindowsVersion.V10_0_18362_0 -> [ DotNetFramework FrameworkVersion.V8; DotNet8Windows Net8WindowsVersion.V10_0_17763_0 ]
976988
| DotNet8Windows Net8WindowsVersion.V10_0_19041_0 -> [ DotNetFramework FrameworkVersion.V8; DotNet8Windows Net8WindowsVersion.V10_0_18362_0 ]
989+
// remark: for now, windows version for net 9 is alias to 8
977990
| DotNetStandard DotNetStandardVersion.V1_0 -> [ ]
978991
| DotNetStandard DotNetStandardVersion.V1_1 -> [ DotNetStandard DotNetStandardVersion.V1_0 ]
979992
| DotNetStandard DotNetStandardVersion.V1_2 -> [ DotNetStandard DotNetStandardVersion.V1_1 ]
@@ -1530,6 +1543,7 @@ module KnownTargetProfiles =
15301543
FrameworkVersion.V6
15311544
FrameworkVersion.V7
15321545
FrameworkVersion.V8
1546+
FrameworkVersion.V9
15331547
]
15341548

15351549
let DotNetFrameworkIdentifiers =
@@ -1634,6 +1648,11 @@ module KnownTargetProfiles =
16341648
DotNet8WindowsVersions
16351649
|> List.map (DotNet8Windows >> TargetProfile.SinglePlatform)
16361650

1651+
let DotNet9OperatingSystems = DotNet8OperatingSystems
1652+
let DotNet9WithOsProfiles = DotNet8WithOsProfiles
1653+
let DotNet9WindowsVersions = DotNet8WindowsVersions
1654+
let DotNet9WindowsProfiles = DotNet8WindowsProfiles
1655+
16371656
let DotNetStandardVersions = [
16381657
DotNetStandardVersion.V1_0
16391658
DotNetStandardVersion.V1_1
@@ -1805,6 +1824,8 @@ module KnownTargetProfiles =
18051824

18061825
let AllDotNetProfiles =
18071826
DotNetFrameworkProfiles @
1827+
DotNet9WithOsProfiles @
1828+
DotNet9WindowsProfiles @
18081829
DotNet8WithOsProfiles @
18091830
DotNet8WindowsProfiles @
18101831
DotNet7WithOsProfiles @

src/Paket.Core/Versioning/PlatformMatching.fs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,14 @@ let getTargetCondition (target:TargetProfile) =
213213
match target with
214214
| TargetProfile.SinglePlatform(platform) ->
215215
match platform with
216+
| DotNetFramework(FrameworkVersion.V9) ->"$(TargetFrameworkIdentifier) == '.NETCoreApp'", "$(TargetFrameworkVersion) == 'v9.0'"
216217
| DotNetFramework(FrameworkVersion.V8) ->"$(TargetFrameworkIdentifier) == '.NETCoreApp'", "$(TargetFrameworkVersion) == 'v8.0'"
217218
| DotNetFramework(FrameworkVersion.V7) ->"$(TargetFrameworkIdentifier) == '.NETCoreApp'", "$(TargetFrameworkVersion) == 'v7.0'"
218219
| DotNetFramework(FrameworkVersion.V6) ->"$(TargetFrameworkIdentifier) == '.NETCoreApp'", "$(TargetFrameworkVersion) == 'v6.0'"
219220
| DotNetFramework(FrameworkVersion.V5) ->"$(TargetFrameworkIdentifier) == '.NETCoreApp'", "$(TargetFrameworkVersion) == 'v5.0'"
220221
| DotNetFramework(version) ->"$(TargetFrameworkIdentifier) == '.NETFramework'", sprintf "$(TargetFrameworkVersion) == '%O'" version
222+
| DotNet9WithOs(os) ->"$(TargetFrameworkIdentifier) == '.NETCoreApp'", sprintf "($(TargetFrameworkVersion) == 'v9.0' And '$(TargetPlatformIdentifier)' == '%O')" os
223+
| DotNet9Windows(version) ->"$(TargetFrameworkIdentifier) == '.NETCoreApp'", sprintf "($(TargetFrameworkVersion) == 'v9.0' And '$(TargetPlatformIdentifier)' == 'Windows' And '$(TargetPlatformVersion)' == '%O')" version
221224
| DotNet8WithOs(os) ->"$(TargetFrameworkIdentifier) == '.NETCoreApp'", sprintf "($(TargetFrameworkVersion) == 'v8.0' And '$(TargetPlatformIdentifier)' == '%O')" os
222225
| DotNet8Windows(version) ->"$(TargetFrameworkIdentifier) == '.NETCoreApp'", sprintf "($(TargetFrameworkVersion) == 'v8.0' And '$(TargetPlatformIdentifier)' == 'Windows' And '$(TargetPlatformVersion)' == '%O')" version
223226
| DotNet7WithOs(os) ->"$(TargetFrameworkIdentifier) == '.NETCoreApp'", sprintf "($(TargetFrameworkVersion) == 'v7.0' And '$(TargetPlatformIdentifier)' == '%O')" os

tests/Paket.Tests/DependenciesFile/ParserSpecs.fs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,21 @@ let ``should read config with .NET 8 target framework``() =
12731273
|> getExplicitRestriction
12741274
|> shouldEqual (FrameworkRestriction.AtLeast(FrameworkIdentifier.DotNetFramework(FrameworkVersion.V8)))
12751275

1276+
let configNET9TargetFramework = """source https://www.nuget.org/api/v2
1277+
1278+
framework: >= net9.0
1279+
1280+
nuget System.Data.SQLite 1.0.98.1 content: none
1281+
"""
1282+
1283+
[<Test>]
1284+
let ``should read config with .NET 9 target framework``() =
1285+
let cfg = DependenciesFile.FromSource(configNET9TargetFramework)
1286+
1287+
cfg.Groups.[Constants.MainDependencyGroup].Options.Settings.FrameworkRestrictions
1288+
|> getExplicitRestriction
1289+
|> shouldEqual (FrameworkRestriction.AtLeast(FrameworkIdentifier.DotNetFramework(FrameworkVersion.V9)))
1290+
12761291
let validFrameworks =
12771292
let net40 = DotNetFramework(FrameworkVersion.V4)
12781293
let net45 = DotNetFramework(FrameworkVersion.V4_5)

tests/Paket.Tests/Versioning/PlatformMatchingSpecs.fs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,30 @@ let ``Can detect a bunch of net8 platforms``() =
311311
if not (List.isEmpty errors) then
312312
failwith (String.concat "\n" errors)
313313

314+
[<Test>]
315+
let ``Can detect a bunch of net9 platforms``() =
316+
let testSet = [
317+
"net9" , TargetProfile.SinglePlatform (FrameworkIdentifier.DotNetFramework FrameworkVersion.V9)
318+
"net9000" , TargetProfile.SinglePlatform (FrameworkIdentifier.DotNetFramework FrameworkVersion.V9)
319+
"net9.0-windows" , TargetProfile.SinglePlatform (FrameworkIdentifier.DotNet9Windows Net9WindowsVersion.V7_0)
320+
"net9-windows" , TargetProfile.SinglePlatform (FrameworkIdentifier.DotNet9Windows Net9WindowsVersion.V7_0)
321+
"net9.0-windows10.0.19041.0" , TargetProfile.SinglePlatform (FrameworkIdentifier.DotNet9Windows Net9WindowsVersion.V10_0_19041_0)
322+
"net9.0-windows10.0.19041" , TargetProfile.SinglePlatform (FrameworkIdentifier.DotNet9Windows Net9WindowsVersion.V10_0_19041_0)
323+
"net9-windows10.0.19041" , TargetProfile.SinglePlatform (FrameworkIdentifier.DotNet9Windows Net9WindowsVersion.V10_0_19041_0)
324+
"net9000-windows10.0.19041" , TargetProfile.SinglePlatform (FrameworkIdentifier.DotNet9Windows Net9WindowsVersion.V10_0_19041_0)
325+
"net9.0-android30.0" , TargetProfile.SinglePlatform (FrameworkIdentifier.DotNet9WithOs Net9Os.Android)
326+
]
327+
328+
let errors = [
329+
for p, expected in testSet do
330+
let parsed = (PlatformMatching.forceExtractPlatforms p).ToTargetProfile false
331+
if parsed <> Some expected then
332+
sprintf "%s resulted into %A instead of %A" p parsed expected
333+
]
334+
335+
if not (List.isEmpty errors) then
336+
failwith (String.concat "\n" errors)
337+
314338
[<Test>]
315339
let ``Can detect netstandard1.6``() =
316340
let p = PlatformMatching.forceExtractPlatforms "netstandard1.6"

0 commit comments

Comments
 (0)