Skip to content

Commit df39190

Browse files
authored
Merge pull request #4248 from smoothdeveloper/paket-supports-dotnet-9
handling for dotnet 9
2 parents 4954f9f + a8f2e39 commit df39190

File tree

7 files changed

+77
-7
lines changed

7 files changed

+77
-7
lines changed

RELEASE_NOTES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#### 8.1.0-alpha002 - 2024-03-14
2+
* Preview support for .NET 9.0 - https://github.com/fsprojects/Paket/pull/4248
3+
14
#### 8.1.0-alpha001 - 2024-01-30
25
* BUGFIX: Aliases should not be inherited - https://github.com/fsprojects/Paket/pull/4244
36

src/Paket.Core/Versioning/FrameworkHandling.fs

Lines changed: 29 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 ]
@@ -1089,6 +1102,7 @@ module FrameworkDetection =
10891102
| Some "6" when dotnetVersionX = 6 -> tryParseSecondPart parts.[1]
10901103
| Some "7" when dotnetVersionX = 7 -> tryParseSecondPart parts.[1]
10911104
| Some "8" when dotnetVersionX = 8 -> tryParseSecondPart parts.[1]
1105+
| Some "9" when dotnetVersionX = 9 -> tryParseSecondPart parts.[1]
10921106
| _ -> None
10931107
else
10941108
None
@@ -1103,6 +1117,7 @@ module FrameworkDetection =
11031117
| Some "6" when dotnetVersionX = 6 -> tryParseVersion winVersionPart
11041118
| Some "7" when dotnetVersionX = 7 -> tryParseVersion winVersionPart
11051119
| Some "8" when dotnetVersionX = 8 -> tryParseVersion winVersionPart
1120+
| Some "9" when dotnetVersionX = 9 -> tryParseVersion winVersionPart
11061121
| _ -> None
11071122
else
11081123
None
@@ -1142,10 +1157,12 @@ module FrameworkDetection =
11421157
// http://nugettoolsdev.azurewebsites.net/4.0.0/parse-framework?framework=.NETPortable%2CVersion%3Dv0.0%2CProfile%3DProfile2
11431158
let result =
11441159
match path with
1160+
| MatchNetXDashWindows 9 Net9WindowsVersion.TryParse fm -> Some (DotNet9Windows fm)
11451161
| MatchNetXDashWindows 8 Net8WindowsVersion.TryParse fm -> Some (DotNet8Windows fm)
11461162
| MatchNetXDashWindows 7 Net7WindowsVersion.TryParse fm -> Some (DotNet7Windows fm)
11471163
| MatchNetXDashWindows 6 Net6WindowsVersion.TryParse fm -> Some (DotNet6Windows fm)
11481164
| MatchNetXDashWindows 5 Net5WindowsVersion.TryParse fm -> Some (DotNet5Windows fm)
1165+
| MatchNetXDashOs 9 Net9Os.TryParse fm -> Some (DotNet9WithOs fm)
11491166
| MatchNetXDashOs 8 Net8Os.TryParse fm -> Some (DotNet8WithOs fm)
11501167
| MatchNetXDashOs 7 Net7Os.TryParse fm -> Some (DotNet7WithOs fm)
11511168
| MatchNetXDashOs 6 Net6Os.TryParse fm -> Some (DotNet6WithOs fm)
@@ -1530,6 +1547,7 @@ module KnownTargetProfiles =
15301547
FrameworkVersion.V6
15311548
FrameworkVersion.V7
15321549
FrameworkVersion.V8
1550+
FrameworkVersion.V9
15331551
]
15341552

15351553
let DotNetFrameworkIdentifiers =
@@ -1634,6 +1652,11 @@ module KnownTargetProfiles =
16341652
DotNet8WindowsVersions
16351653
|> List.map (DotNet8Windows >> TargetProfile.SinglePlatform)
16361654

1655+
let DotNet9OperatingSystems = DotNet8OperatingSystems
1656+
let DotNet9WithOsProfiles = DotNet8WithOsProfiles
1657+
let DotNet9WindowsVersions = DotNet8WindowsVersions
1658+
let DotNet9WindowsProfiles = DotNet8WindowsProfiles
1659+
16371660
let DotNetStandardVersions = [
16381661
DotNetStandardVersion.V1_0
16391662
DotNetStandardVersion.V1_1
@@ -1805,6 +1828,8 @@ module KnownTargetProfiles =
18051828

18061829
let AllDotNetProfiles =
18071830
DotNetFrameworkProfiles @
1831+
DotNet9WithOsProfiles @
1832+
DotNet9WindowsProfiles @
18081833
DotNet8WithOsProfiles @
18091834
DotNet8WindowsProfiles @
18101835
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)

0 commit comments

Comments
 (0)