From b9edc150b138ab52b95b0b088f6a1f02742b9095 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 | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/workload/scripts/workload-install.ps1 b/workload/scripts/workload-install.ps1 index fa0c031..f2eed08 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,28 @@ 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); + $MatchingFallbackId = @() + foreach ($key in $LatestVersionMap.Keys) { + if ($key -like "$SubStringId*") { + $MatchingFallbackId += $key + } + } + if ($MatchingFallbackId) + { + $FallbackId = $MatchingFallbackId[-1] + return $FallbackId + } + } + + Write-Error "Wrong Id: $Id" } function Get-Package([string]$Id, [string]$Version, [string]$Destination, [string]$FileExt = "nupkg") {