From ac305b369daf86b6e1a731756a705454fc393335 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Thu, 10 Apr 2025 18:18:56 +0300 Subject: [PATCH] Fix .NET SDK detection when only the runtime is installed --- Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs b/Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs index 7d4866bf8..2981a2b70 100644 --- a/Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs +++ b/Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs @@ -235,8 +235,8 @@ namespace Flax.Build ridFallback = ""; if (string.IsNullOrEmpty(dotnetPath)) { - dotnetPath = "/usr/local/share/dotnet/"; - if (!Directory.Exists(dotnetPath)) // Officially recommended dotnet location + dotnetPath = "/usr/local/share/dotnet/"; // Officially recommended dotnet location + if (!Directory.Exists(dotnetPath)) { if (Environment.GetEnvironmentVariable("PATH") is string globalBinPath) dotnetPath = globalBinPath.Split(':').FirstOrDefault(x => File.Exists(Path.Combine(x, "dotnet"))); @@ -261,7 +261,7 @@ namespace Flax.Build Log.Warning("Missing .NET SDK"); return; } - if (!Directory.Exists(dotnetPath)) + if (!Directory.Exists(Path.Combine(dotnetPath, "sdk"))) { Log.Warning($"Missing .NET SDK ({dotnetPath})"); return; @@ -513,6 +513,8 @@ namespace Flax.Build private static IEnumerable GetVersions(string folder) { + if (!Directory.Exists(folder)) + return Enumerable.Empty(); return Directory.GetDirectories(folder).Select(Path.GetFileName); }