C#: Fix buildsystem when `dotnet --info` does not specify arch

For some installations the architecture information is not printed.
This commit is contained in:
Ignacio Roldán Etcheverry 2022-08-25 20:04:23 +02:00
parent 88145e81e2
commit 09af583e10
1 changed files with 9 additions and 1 deletions

View File

@ -287,6 +287,10 @@ def find_dotnet_executable(arch):
os.path.join(dir, "arm32"), os.path.join(dir, "arm32"),
] # search subfolders for cross compiling ] # search subfolders for cross compiling
# `dotnet --info` may not specify architecture. In such cases,
# we fallback to the first one we find without architecture.
sdk_path_unknown_arch = ""
for dir in search_dirs: for dir in search_dirs:
path = os.path.join(dir, "dotnet") path = os.path.join(dir, "dotnet")
@ -298,10 +302,14 @@ def find_dotnet_executable(arch):
sdk_arch = find_dotnet_arch(path_with_ext) sdk_arch = find_dotnet_arch(path_with_ext)
if sdk_arch == arch or arch == "": if sdk_arch == arch or arch == "":
return path_with_ext return path_with_ext
elif sdk_arch == "":
sdk_path_unknown_arch = path_with_ext
else: else:
if os.path.isfile(path) and os.access(path, os.X_OK): if os.path.isfile(path) and os.access(path, os.X_OK):
sdk_arch = find_dotnet_arch(path) sdk_arch = find_dotnet_arch(path)
if sdk_arch == arch or arch == "": if sdk_arch == arch or arch == "":
return path return path
elif sdk_arch == "":
sdk_path_unknown_arch = path
return "" return sdk_path_unknown_arch