Skip to content

Commit 458e44b

Browse files
authored
Fix loading of dotnet10 (#104)
Also sort versions as numbers instead of strings, so that 10 is greater than 9
1 parent 5522e80 commit 458e44b

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

clr_loader/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def get_coreclr(
139139
candidates = [
140140
rt for rt in find_runtimes() if rt.name == "Microsoft.NETCore.App"
141141
]
142-
candidates.sort(key=lambda spec: spec.version, reverse=True)
142+
candidates.sort(key=lambda spec: spec.version_info, reverse=True)
143143
if not candidates:
144144
raise RuntimeError("Failed to find a suitable runtime")
145145

clr_loader/util/runtime_spec.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import json
22
from dataclasses import dataclass
33
from pathlib import Path
4-
from typing import Any, Dict, TextIO
4+
from typing import Any, Dict, TextIO, Tuple
55

66

77
@dataclass
@@ -12,14 +12,19 @@ class DotnetCoreRuntimeSpec:
1212
version: str
1313
path: Path
1414

15+
@property
16+
def version_info(self) -> Tuple[int, int, int, str]:
17+
base, _, suffix = self.version.partition("-")
18+
major, minor, patch = base.split(".")
19+
return (int(major), int(minor), int(patch), suffix)
20+
1521
@property
1622
def tfm(self) -> str:
17-
return f"net{self.version[:3]}"
23+
return f"net{self.version_info[0]}.{self.version_info[1]}"
1824

1925
@property
2026
def floor_version(self) -> str:
21-
major, minor, _ = self.version.split(".")
22-
return f"{major}.{minor}.0"
27+
return f"{self.version_info[0]}.{self.version_info[1]}.0"
2328

2429
@property
2530
def runtime_config(self) -> Dict[str, Any]:

0 commit comments

Comments
 (0)