Skip to content

Commit 15ede71

Browse files
committed
Allow loading libhostfxr directly from the dotnet_root
This is a prerequisite to load self-contained components (which is still not supported upstream, though).
1 parent 9c24c89 commit 15ede71

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

clr_loader/ffi/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
def load_hostfxr(dotnet_root: Path):
1818
hostfxr_name = _get_dll_name("hostfxr")
19+
dotnet_root = dotnet_root.absolute()
1920

2021
# This will fail as soon as .NET hits version 10, but hopefully by then
2122
# we'll have a more robust way of finding the libhostfxr
@@ -28,6 +29,11 @@ def load_hostfxr(dotnet_root: Path):
2829
except Exception:
2930
pass
3031

32+
try:
33+
return ffi.dlopen(str(dotnet_root / hostfxr_name))
34+
except Exception:
35+
pass
36+
3137
raise RuntimeError(f"Could not find a suitable hostfxr library in {dotnet_root}")
3238

3339

0 commit comments

Comments
 (0)