diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs b/build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs index e1808adc328..ce0220fdf71 100644 --- a/build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs +++ b/build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs @@ -21,7 +21,8 @@ protected override async Task Execute (Context context) var dotnetPath = Configurables.Paths.DotNetPreviewPath; dotnetPath = dotnetPath.TrimEnd (new char [] { Path.DirectorySeparatorChar }); - if (!await InstallDotNetAsync (context, dotnetPath, BuildToolVersion)) { + if (!await InstallDotNetAsync (context, dotnetPath, BuildToolVersion, useCachedInstallScript: true) && + !await InstallDotNetAsync (context, dotnetPath, BuildToolVersion, useCachedInstallScript: false)) { Log.ErrorLine ($"Installation of dotnet SDK '{BuildToolVersion}' failed."); return false; } @@ -77,17 +78,18 @@ protected override async Task Execute (Context context) return true; } - async Task DownloadDotNetInstallScript (Context context, string dotnetScriptPath, Uri dotnetScriptUrl) + async Task DownloadDotNetInstallScript (Context context, string dotnetScriptPath, Uri dotnetScriptUrl, bool useCachedInstallScript) { string tempDotnetScriptPath = dotnetScriptPath + "-tmp"; Utilities.DeleteFile (tempDotnetScriptPath); Log.StatusLine ("Downloading dotnet-install script..."); - if (File.Exists (dotnetScriptPath)) { + if (useCachedInstallScript && File.Exists (dotnetScriptPath)) { Log.WarningLine ($"Using cached installation script found in '{dotnetScriptPath}'"); return true; } + Utilities.DeleteFile (dotnetScriptPath); Log.StatusLine ($" {context.Characters.Link} {dotnetScriptUrl}", ConsoleColor.White); await Utilities.Download (dotnetScriptUrl, tempDotnetScriptPath, DownloadStatus.Empty); @@ -173,7 +175,7 @@ string[] GetInstallationScriptArgs (string version, string dotnetPath, string do return args.ToArray (); } - async Task InstallDotNetAsync (Context context, string dotnetPath, string version, bool runtimeOnly = false) + async Task InstallDotNetAsync (Context context, string dotnetPath, string version, bool useCachedInstallScript, bool runtimeOnly = false) { string cacheDir = context.Properties.GetRequiredValue (KnownProperties.AndroidToolchainCacheDirectory); @@ -183,7 +185,7 @@ async Task InstallDotNetAsync (Context context, string dotnetPath, string Uri dotnetScriptUrl = Configurables.Urls.DotNetInstallScript; string scriptFileName = Path.GetFileName (dotnetScriptUrl.LocalPath); string cachedDotnetScriptPath = Path.Combine (cacheDir, scriptFileName); - if (!await DownloadDotNetInstallScript (context, cachedDotnetScriptPath, dotnetScriptUrl)) { + if (!await DownloadDotNetInstallScript (context, cachedDotnetScriptPath, dotnetScriptUrl, useCachedInstallScript)) { return false; }