From dc06d085e199d9176474826004bae3dc5afaf5c2 Mon Sep 17 00:00:00 2001 From: Jay Cho Date: Fri, 16 Aug 2024 14:48:56 +0900 Subject: [PATCH] Apply Fallback Install --- workload/scripts/workload-install.ps1 | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/workload/scripts/workload-install.ps1 b/workload/scripts/workload-install.ps1 index fa0c031..affd1e2 100644 --- a/workload/scripts/workload-install.ps1 +++ b/workload/scripts/workload-install.ps1 @@ -28,7 +28,7 @@ $ProgressPreference = "SilentlyContinue" $ManifestBaseName = "Samsung.NET.Sdk.Tizen.Manifest" -$LatestVersionMap = @{ +$LatestVersionMap = [ordered]@{ "$ManifestBaseName-6.0.100" = "7.0.101"; "$ManifestBaseName-6.0.200" = "7.0.100-preview.13.6"; "$ManifestBaseName-6.0.300" = "8.0.133"; @@ -95,13 +95,29 @@ function Get-LatestVersion([string]$Id) { if ($attempts -gt 0) { Start-Sleep $sleepInSeconds } } while ($attempts -gt 0) - if ($LatestVersionMap.ContainsKey($Id)) + if ($LatestVersionMap.Contains($Id)) { Write-Host "Return cached latest version." return $LatestVersionMap.$Id - } else { - Write-Error "Wrong Id: $Id" } + else + { + $SubStringId = $Id.Substring(0, $ManifestBaseName.Length + 2); + $MatchingFallbackVersion = @() + foreach ($key in $LatestVersionMap.Keys) { + if ($key -like "$SubStringId*") { + $MatchingFallbackVersion += $key + } + } + if ($MatchingFallbackVersion) + { + $FallbackVersion = $MatchingFallbackVersion[-1] + Write-Host "Return fallback version: $FallbackVersion" + return $FallbackVersion + } + } + + Write-Error "Wrong Id: $Id" } function Get-Package([string]$Id, [string]$Version, [string]$Destination, [string]$FileExt = "nupkg") {