Improve Dotnet version setup for Game Cooker

Especially after #3371 change to not passing dotnet 8 when packaging engine so editor can use the one use at compile time.
This commit is contained in:
Wojtek Figat
2025-04-13 20:22:23 +02:00
parent 85ecbaab6d
commit f70ec896b8
2 changed files with 21 additions and 5 deletions

View File

@@ -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
/// <summary>
/// Game building options. Used as flags.
/// </summary>

View File

@@ -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");
}
}
/// <inheritdoc />