From 428ebf7fd781df4c8117e48fe11deaf2b550c2ae Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Mon, 27 Jan 2025 20:06:06 +0200 Subject: [PATCH] Fix .NET runtime and SDK compilation issues with newer runtime --- Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs b/Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs index 093b2b39e..3bf49a33a 100644 --- a/Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs +++ b/Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs @@ -282,6 +282,17 @@ namespace Flax.Build var dotnetSdkVersion = GetVersion(dotnetSdkVersions); var dotnetRuntimeVersion = GetVersion(dotnetRuntimeVersions); + if (!string.IsNullOrEmpty(dotnetRuntimeVersion) && ParseVersion(dotnetRuntimeVersion).Major > ParseVersion(dotnetSdkVersion).Major) + { + // Make sure the reference assemblies are not newer than the SDK itself + var dotnetRuntimeVersionsRemaining = dotnetRuntimeVersions; + do + { + dotnetRuntimeVersionsRemaining = dotnetRuntimeVersionsRemaining.Skip(1); + dotnetRuntimeVersion = GetVersion(dotnetRuntimeVersionsRemaining); + } while (!string.IsNullOrEmpty(dotnetRuntimeVersion) && ParseVersion(dotnetRuntimeVersion).Major > ParseVersion(dotnetSdkVersion).Major); + } + var minVer = string.IsNullOrEmpty(Configuration.Dotnet) ? MinimumVersion.ToString() : Configuration.Dotnet; if (string.IsNullOrEmpty(dotnetSdkVersion)) {