File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 11import sys
22from pathlib import Path
3- from typing import Optional
3+ from typing import Optional , Tuple
44
55import cffi # type: ignore
66
@@ -23,7 +23,7 @@ def load_hostfxr(dotnet_root: Path):
2323 hostfxr_path = dotnet_root / "host" / "fxr"
2424 hostfxr_paths = hostfxr_path .glob (f"?.*/{ hostfxr_name } " )
2525
26- for hostfxr_path in reversed (sorted (hostfxr_paths )):
26+ for hostfxr_path in reversed (sorted (hostfxr_paths , key = _path_to_version )):
2727 try :
2828 return ffi .dlopen (str (hostfxr_path ))
2929 except Exception :
@@ -61,6 +61,15 @@ def load_netfx():
6161 return ffi .dlopen (str (path ))
6262
6363
64+ def _path_to_version (path : Path ) -> Tuple [int , int , int ]:
65+ name = path .parent .name
66+ try :
67+ res = list (map (int , name .split ("." )))
68+ return tuple (res + [0 , 0 , 0 ])[:3 ]
69+ except Exception :
70+ return (0 , 0 , 0 )
71+
72+
6473def _get_dll_name (name : str ) -> str :
6574 if sys .platform == "win32" :
6675 return f"{ name } .dll"
You can’t perform that action at this time.
0 commit comments