Skip to content

Commit 299dfc0

Browse files
committed
Fix hostfxr discovery on 32bit Windows
1 parent 80860d9 commit 299dfc0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

clr_loader/hostfxr.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ def __init__(self, runtime_config, dotnet_root=None):
1616
if not dotnet_root:
1717
dotnet_root = os.environ.get("DOTNET_ROOT", None)
1818

19+
if not dotnet_root and sys.platform == 'win32':
20+
# On Windows, the host library is stored separately from dotnet.exe for x86
21+
if sys.maxsize > 2 ** 32:
22+
possible_root = os.path.join(os.environ.get("ProgramFiles"), "dotnet")
23+
else:
24+
possible_root = os.path.join(os.environ.get("ProgramFiles(x86)"), "dotnet")
25+
26+
if os.path.isdir(possible_root):
27+
dotnet_root = possible_root
28+
1929
if not dotnet_root:
2030
dotnet_path = shutil.which("dotnet")
2131
if not dotnet_path:

0 commit comments

Comments
 (0)