Skip to content

Commit

Permalink
Apply Fallback Install
Browse files Browse the repository at this point in the history
  • Loading branch information
JoonghyunCho committed Aug 16, 2024
1 parent 6ee5c63 commit b2afc6c
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions workload/scripts/workload-install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -95,13 +95,32 @@ 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 = @()
$MatchingFallbackVersion = @()
foreach ($key in $LatestVersionMap.Keys) {
if ($key -like "$SubStringId*") {
$MatchingFallbackId += $key
$MatchingFallbackVersion += $LatestVersionMap[$key]
}
}
if ($MatchingFallbackVersion)
{
$global:FallbackId = $MatchingFallbackId[-1]
$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") {
Expand Down Expand Up @@ -228,7 +247,11 @@ function Install-TizenWorkload([string]$DotnetVersion)

# Install workload manifest.
Write-Host "Installing $ManifestName/$Version to $ManifestDir..."
Install-Pack -Id $ManifestName -Version $Version -Kind "manifest"
if ($FallbackId) {
Install-Pack -Id $FallbackId -Version $Version -Kind "manifest"
} else {
Install-Pack -Id $ManifestName -Version $Version -Kind "manifest"
}

# Download and install workload packs.
$NewManifestJson = $(Get-Content $TizenManifestFile | ConvertFrom-Json)
Expand Down

0 comments on commit b2afc6c

Please sign in to comment.