diff --git a/Source/Editor/Cooker/CookingData.h b/Source/Editor/Cooker/CookingData.h
index 3a0e4482b..13db5bb3f 100644
--- a/Source/Editor/Cooker/CookingData.h
+++ b/Source/Editor/Cooker/CookingData.h
@@ -12,17 +12,21 @@
class GameCooker;
class PlatformTools;
+// Range of dotnet runtime versions
+#ifndef GAME_BUILD_DOTNET_RUNTIME_MIN_VER
+#define GAME_BUILD_DOTNET_RUNTIME_MIN_VER 8
+#endif
+#ifndef GAME_BUILD_DOTNET_RUNTIME_MAX_VER
+#define GAME_BUILD_DOTNET_RUNTIME_MAX_VER 9
+#endif
+
#if OFFICIAL_BUILD
// Use the fixed .NET SDK version in packaged builds for compatibility (FlaxGame is precompiled with it)
-#define GAME_BUILD_DOTNET_VER TEXT("-dotnet=8")
+#define GAME_BUILD_DOTNET_VER TEXT("-dotnet=" MACRO_TO_STR(GAME_BUILD_DOTNET_RUNTIME_MIN_VER))
#else
#define GAME_BUILD_DOTNET_VER TEXT("")
#endif
-// Range of dotnet runtime versions
-#define GAME_BUILD_DOTNET_RUNTIME_MIN_VER 8
-#define GAME_BUILD_DOTNET_RUNTIME_MAX_VER 9
-
///
/// Game building options. Used as flags.
///
diff --git a/Source/Editor/Editor.Build.cs b/Source/Editor/Editor.Build.cs
index 699a42ad4..e75954909 100644
--- a/Source/Editor/Editor.Build.cs
+++ b/Source/Editor/Editor.Build.cs
@@ -97,6 +97,18 @@ public class Editor : EditorModule
if (path != null && File.Exists(path))
options.PrivateDefinitions.Add("USE_VISUAL_STUDIO_DTE");
}
+
+ // Setup .NET versions range valid for Game Cooker (minimal is the one used by the native runtime)
+ var dotnetSdk = DotNetSdk.Instance;
+ if (dotnetSdk.IsValid)
+ {
+ var sdkVer = dotnetSdk.Version.Major;
+ var minVer = Math.Max(DotNetSdk.MinimumVersion.Major, sdkVer);
+ var maxVer = DotNetSdk.MaximumVersion.Major;
+ options.PrivateDefinitions.Add("GAME_BUILD_DOTNET_RUNTIME_MIN_VER=" + minVer);
+ options.PrivateDefinitions.Add("GAME_BUILD_DOTNET_RUNTIME_MAX_VER=" + DotNetSdk.MaximumVersion.Major);
+ Log.Verbose($"Using Dotnet runtime versions range {minVer}-{maxVer} for Game Cooker");
+ }
}
///