From 2984211dcdc3df85729ca03daec733be29768173 Mon Sep 17 00:00:00 2001 From: HarithaVattikuti <73516759+HarithaVattikuti@users.noreply.github.com> Date: Wed, 25 Dec 2024 18:47:48 -0600 Subject: [PATCH] Fallback logic --- dist/setup/index.js | 9 ++++++++- src/installer.ts | 19 ++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index f1d37d2..d719bfd 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -71264,7 +71264,13 @@ class DotnetVersionResolver { allowRetries: true, maxRetries: 3 }); - const response = yield httpClient.getJson(DotnetVersionResolver.DotNetCoreIndexUrl); + let response; + try { + response = yield httpClient.getJson(DotnetVersionResolver.DotNetCoreIndexUrl); + } + catch (error) { + response = yield httpClient.getJson(DotnetVersionResolver.DotnetCoreIndexFallbackUrl); + } const result = response.result || {}; const releasesInfo = result['releases-index']; const releaseInfo = releasesInfo.find(info => { @@ -71280,6 +71286,7 @@ class DotnetVersionResolver { } exports.DotnetVersionResolver = DotnetVersionResolver; DotnetVersionResolver.DotNetCoreIndexUrl = 'https://builds.dotnet.microsoft.com/dotnet/release-metadata/releases-index.json'; +DotnetVersionResolver.DotnetCoreIndexFallbackUrl = 'https://dotnetcli.azureedge.net/dotnet/release-metadata/releases-index.json'; class DotnetCoreInstaller { constructor(version, quality) { this.version = version; diff --git a/src/installer.ts b/src/installer.ts index 02331ef..bb236fe 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -101,9 +101,18 @@ export class DotnetVersionResolver { allowRetries: true, maxRetries: 3 }); - const response = await httpClient.getJson( - DotnetVersionResolver.DotNetCoreIndexUrl - ); + + let response; + try { + response = await httpClient.getJson( + DotnetVersionResolver.DotNetCoreIndexUrl + ); + } catch (error) { + response = await httpClient.getJson( + DotnetVersionResolver.DotnetCoreIndexFallbackUrl + ); + } + const result = response.result || {}; const releasesInfo: any[] = result['releases-index']; @@ -123,6 +132,10 @@ export class DotnetVersionResolver { static DotNetCoreIndexUrl = 'https://builds.dotnet.microsoft.com/dotnet/release-metadata/releases-index.json'; + + static DotnetCoreIndexFallbackUrl = + 'https://dotnetcli.azureedge.net/dotnet/release-metadata/releases-index.json'; + } export class DotnetCoreInstaller {