diff --git a/Source/Editor/Cooker/Steps/DeployDataStep.cpp b/Source/Editor/Cooker/Steps/DeployDataStep.cpp index d6d978439..d19c28748 100644 --- a/Source/Editor/Cooker/Steps/DeployDataStep.cpp +++ b/Source/Editor/Cooker/Steps/DeployDataStep.cpp @@ -213,20 +213,16 @@ bool DeployDataStep::Perform(CookingData& data) } FileSystem::NormalizePath(srcDotnet); LOG(Info, "Using .NET Runtime {} at {}", TEXT("Host"), srcDotnet); + const bool srcDotnetFromEngine = srcDotnet.Contains(TEXT("Source/Platforms")); + String packFolder = srcDotnet / TEXT("../../../"); // Get .NET runtime version String version; - if (usAOT) { - // Precompiled - version = StringUtils::ToString(GAME_BUILD_DOTNET_RUNTIME_MIN_VER); - } - else - { - // Detect from path + // Detect from path provided by build tool Array pathParts; srcDotnet.Split('/', pathParts); - for (int i = 0; i < pathParts.Count(); i++) + for (int32 i = 1; i < pathParts.Count(); i++) { if (pathParts[i] == TEXT("runtimes")) { @@ -244,15 +240,32 @@ bool DeployDataStep::Perform(CookingData& data) } if (version.IsEmpty()) { - data.Error(TEXT("Failed to find supported .NET version for the current host platform.")); - return true; + if (srcDotnetFromEngine) + { + // Detect version from runtime files inside Engine Platform folder + for (int32 i = GAME_BUILD_DOTNET_RUNTIME_MAX_VER; i >= GAME_BUILD_DOTNET_RUNTIME_MIN_VER; i--) + { + // Check runtime files inside Engine Platform folder + String testPath1 = srcDotnet / String::Format(TEXT("lib/net{}.0"), i); + String testPath2 = packFolder / String::Format(TEXT("Dotnet/lib/net{}.0"), i); + if ((FileSystem::DirectoryExists(testPath1) && FileSystem::GetDirectorySize(testPath1) > 0) || + (FileSystem::DirectoryExists(testPath2) && FileSystem::GetDirectorySize(testPath2) > 0)) + { + version = StringUtils::ToString(i); + break; + } + } + } + if (version.IsEmpty()) + { + data.Error(TEXT("Failed to find supported .NET version for the current host platform.")); + return true; + } } } // Deploy runtime files const Char* corlibPrivateName = TEXT("System.Private.CoreLib.dll"); - const bool srcDotnetFromEngine = srcDotnet.Contains(TEXT("Source/Platforms")); - String packFolder = srcDotnet / TEXT("../../../"); String dstDotnetLibs = dstDotnet, srcDotnetLibs = srcDotnet; StringUtils::PathRemoveRelativeParts(packFolder); if (usAOT)