Skip to content

Commit cf0ba00

Browse files
Support finding .NET 10 and pre-release .NET versions (#82)
* Support finding .NET 10 and pre-release .NET versions
1 parent bbdc3da commit cf0ba00

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

clr_loader/ffi/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ def load_hostfxr(dotnet_root: Path):
1818
hostfxr_name = _get_dll_name("hostfxr")
1919
dotnet_root = dotnet_root.absolute()
2020

21-
# This will fail as soon as .NET hits version 10, but hopefully by then
22-
# we'll have a more robust way of finding the libhostfxr
21+
# Find all hostfxr versions by looking for the library file in version subdirectories
2322
hostfxr_path = dotnet_root / "host" / "fxr"
24-
hostfxr_paths = hostfxr_path.glob(f"?.*/{hostfxr_name}")
23+
hostfxr_paths = hostfxr_path.glob(f"*/{hostfxr_name}")
2524

2625
error_report = list()
2726

@@ -69,7 +68,9 @@ def load_netfx():
6968
def _path_to_version(path: Path) -> Tuple[int, int, int]:
7069
name = path.parent.name
7170
try:
72-
res = list(map(int, name.split(".")))
71+
# Handle pre-release versions like "10.0.0-rc.1" by taking only the version part
72+
version_part = name.split("-")[0]
73+
res = list(map(int, version_part.split(".")))
7374
return tuple(res + [0, 0, 0])[:3]
7475
except Exception:
7576
return (0, 0, 0)

0 commit comments

Comments
 (0)