From 7445064d9738213785586ad413aea049f44e2ce2 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sun, 14 Dec 2025 20:16:33 +0200 Subject: [PATCH 1/3] Improve installed .NET runtime version detection --- Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs b/Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs index 28c3958df..d1c24e5cd 100644 --- a/Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs +++ b/Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs @@ -282,7 +282,7 @@ namespace Flax.Build dotnetRuntimeVersions = MergeVersions(dotnetRuntimeVersions, GetVersions(Path.Combine(dotnetPath, "shared", "Microsoft.NETCore.App"))); dotnetSdkVersions = dotnetSdkVersions.Where(x => File.Exists(Path.Combine(dotnetPath, "sdk", x, ".version"))); - dotnetRuntimeVersions = dotnetRuntimeVersions.Where(x => File.Exists(Path.Combine(dotnetPath, "shared", "Microsoft.NETCore.App", x, ".version"))); + dotnetRuntimeVersions = dotnetRuntimeVersions.Where(x => File.Exists(Path.Combine(dotnetPath, "shared", "Microsoft.NETCore.App", x, "System.dll"))); dotnetRuntimeVersions = dotnetRuntimeVersions.Where(x => Directory.Exists(Path.Combine(dotnetPath, "packs", "Microsoft.NETCore.App.Ref", x))); dotnetSdkVersions = dotnetSdkVersions.OrderByDescending(ParseVersion); From 5cd27032b41c31b583f967b7f6e938f583a05630 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sun, 14 Dec 2025 20:18:21 +0200 Subject: [PATCH 2/3] Set C# language version to 14 with .NET 10 --- Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs b/Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs index d1c24e5cd..137a22ccc 100644 --- a/Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs +++ b/Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs @@ -166,6 +166,7 @@ namespace Flax.Build /// public string CSharpLanguageVersion => Version.Major switch { + _ when Version.Major >= 10 => "14.0", _ when Version.Major >= 9 => "13.0", _ when Version.Major >= 8 => "12.0", _ when Version.Major >= 7 => "11.0", From ae03bc2dd27c10f93813a23b97bb5de2e7306b8d Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sun, 14 Dec 2025 20:24:39 +0200 Subject: [PATCH 3/3] Improve Linux .NET runtime identifier detection Use the runtime identifier detected during runtime instead of calling the dotnet tool in order to query it. --- .../Flax.Build/Build/DotNet/DotNetSdk.cs | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs b/Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs index 137a22ccc..de0fa755c 100644 --- a/Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs +++ b/Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs @@ -4,6 +4,7 @@ using System; using System.IO; using System.Linq; using System.Collections.Generic; +using System.Runtime.InteropServices; using Microsoft.Win32; namespace Flax.Build @@ -187,7 +188,7 @@ namespace Flax.Build // Find system-installed SDK string dotnetPath = Environment.GetEnvironmentVariable("DOTNET_ROOT"); - string rid, ridFallback, arch; + string arch; IEnumerable dotnetSdkVersions = null, dotnetRuntimeVersions = null; switch (architecture) { @@ -209,8 +210,6 @@ namespace Flax.Build { case TargetPlatform.Windows: { - rid = $"win-{arch}"; - ridFallback = ""; #pragma warning disable CA1416 if (string.IsNullOrEmpty(dotnetPath)) { @@ -235,16 +234,12 @@ namespace Flax.Build } case TargetPlatform.Linux: { - rid = $"linux-{arch}"; - ridFallback = Utilities.ReadProcessOutput("dotnet", "--info").Split('\n').FirstOrDefault(x => x.StartsWith(" RID:"), "").Replace("RID:", "").Trim(); if (string.IsNullOrEmpty(dotnetPath)) dotnetPath ??= SearchForDotnetLocationLinux(); break; } case TargetPlatform.Mac: { - rid = $"osx-{arch}"; - ridFallback = ""; if (string.IsNullOrEmpty(dotnetPath)) { dotnetPath = "/usr/local/share/dotnet/"; // Officially recommended dotnet location @@ -258,7 +253,6 @@ namespace Flax.Build } if (Flax.Build.Platforms.MacPlatform.BuildingForx64) { - rid = "osx-x64"; dotnetPath = Path.Combine(dotnetPath, "x64"); architecture = TargetArchitecture.x64; } @@ -332,6 +326,20 @@ namespace Flax.Build VersionName = dotnetSdkVersion; RuntimeVersionName = dotnetRuntimeVersion; + string rid, ridFallback = ""; + switch (platform) + { + case TargetPlatform.Windows: rid = $"win-{arch}"; break; + case TargetPlatform.Linux: + { + rid = RuntimeInformation.RuntimeIdentifier; + ridFallback = $"linux-{arch}"; + break; + } + case TargetPlatform.Mac: rid = Flax.Build.Platforms.MacPlatform.BuildingForx64 ? "osx-x64" : $"osx-{arch}"; break; + default: throw new InvalidPlatformException(platform); + } + // Pick SDK runtime if (!TryAddHostRuntime(platform, architecture, rid) && !TryAddHostRuntime(platform, architecture, ridFallback)) {