From 4eaac4ab2ffde090a215a55b155d11d1e2e7cd71 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sun, 19 Nov 2023 10:51:27 +0200 Subject: [PATCH 1/2] Fix building Flax.Build with .NET 8 SDK --- Source/Tools/Flax.Build/global.json | 2 +- global.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Tools/Flax.Build/global.json b/Source/Tools/Flax.Build/global.json index a6e7dc6c3..3fe9e80f6 100644 --- a/Source/Tools/Flax.Build/global.json +++ b/Source/Tools/Flax.Build/global.json @@ -1,6 +1,6 @@ { "sdk": { "version": "7.0.0", - "rollForward": "latestMinor" + "rollForward": "latestMajor" } } \ No newline at end of file diff --git a/global.json b/global.json index a6e7dc6c3..3fe9e80f6 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { "version": "7.0.0", - "rollForward": "latestMinor" + "rollForward": "latestMajor" } } \ No newline at end of file From 017e7cbc60f551de40e36e2d904c16dad6e0b7a4 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sun, 19 Nov 2023 11:25:04 +0200 Subject: [PATCH 2/2] Validate detected .NET SDK/runtime versions --- Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs b/Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs index c2999999d..8eea4d6dd 100644 --- a/Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs +++ b/Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs @@ -249,11 +249,17 @@ namespace Flax.Build if (dotnetSdkVersions == null) dotnetSdkVersions = GetVersions(Path.Combine(dotnetPath, "sdk")); if (dotnetRuntimeVersions == null) - dotnetRuntimeVersions = GetVersions(Path.Combine(dotnetPath, "shared/Microsoft.NETCore.App")); + dotnetRuntimeVersions = GetVersions(Path.Combine(dotnetPath, "shared", "Microsoft.NETCore.App")); + + dotnetSdkVersions = dotnetSdkVersions.Where(x => IsValidVersion(Path.Combine(dotnetPath, "sdk", x))); + dotnetRuntimeVersions = dotnetRuntimeVersions.Where(x => IsValidVersion(Path.Combine(dotnetPath, "shared", "Microsoft.NETCore.App", x))); dotnetSdkVersions = dotnetSdkVersions.OrderByDescending(ParseVersion); dotnetRuntimeVersions = dotnetRuntimeVersions.OrderByDescending(ParseVersion); + Log.Verbose($"Found the following .NET SDK versions: {string.Join(", ", dotnetSdkVersions)}"); + Log.Verbose($"Found the following .NET runtime versions: {string.Join(", ", dotnetRuntimeVersions)}"); + string dotnetSdkVersion = dotnetSdkVersions.FirstOrDefault(x => ParseVersion(x).Major >= MinimumVersion.Major && ParseVersion(x).Major <= MaximumVersion.Major); string dotnetRuntimeVersion = dotnetRuntimeVersions.FirstOrDefault(x => ParseVersion(x).Major >= MinimumVersion.Major && ParseVersion(x).Major <= MaximumVersion.Major); if (string.IsNullOrEmpty(dotnetSdkVersion)) @@ -276,7 +282,7 @@ namespace Flax.Build // Pick SDK runtime if (!TryAddHostRuntime(platform, architecture, rid) && !TryAddHostRuntime(platform, architecture, ridFallback)) { - var path = Path.Combine(RootPath, $"packs/Microsoft.NETCore.App.Host.{rid}/{RuntimeVersionName}/runtimes/{rid}/native"); + var path = Path.Combine(RootPath, "packs", $"Microsoft.NETCore.App.Host.{rid}", RuntimeVersionName, "runtimes", rid, "native"); Log.Warning($"Missing .NET SDK host runtime for {platform} {architecture} ({path})."); return; } @@ -465,6 +471,11 @@ namespace Flax.Build .FirstOrDefault(); } + private static bool IsValidVersion(string versionPath) + { + return File.Exists(Path.Combine(versionPath, ".version")); + } + private static string SearchForDotnetLocationLinux() { if (File.Exists("/etc/dotnet/install_location")) // Officially recommended dotnet location file