@@ -21,7 +21,8 @@ protected override async Task<bool> Execute (Context context)
2121 var dotnetPath = Configurables . Paths . DotNetPreviewPath ;
2222 dotnetPath = dotnetPath . TrimEnd ( new char [ ] { Path . DirectorySeparatorChar } ) ;
2323
24- if ( ! await InstallDotNetAsync ( context , dotnetPath , BuildToolVersion ) ) {
24+ if ( ! await InstallDotNetAsync ( context , dotnetPath , BuildToolVersion , useCachedInstallScript : true ) &&
25+ ! await InstallDotNetAsync ( context , dotnetPath , BuildToolVersion , useCachedInstallScript : false ) ) {
2526 Log . ErrorLine ( $ "Installation of dotnet SDK '{ BuildToolVersion } ' failed.") ;
2627 return false ;
2728 }
@@ -77,17 +78,18 @@ protected override async Task<bool> Execute (Context context)
7778 return true ;
7879 }
7980
80- async Task < bool > DownloadDotNetInstallScript ( Context context , string dotnetScriptPath , Uri dotnetScriptUrl )
81+ async Task < bool > DownloadDotNetInstallScript ( Context context , string dotnetScriptPath , Uri dotnetScriptUrl , bool useCachedInstallScript )
8182 {
8283 string tempDotnetScriptPath = dotnetScriptPath + "-tmp" ;
8384 Utilities . DeleteFile ( tempDotnetScriptPath ) ;
8485
8586 Log . StatusLine ( "Downloading dotnet-install script..." ) ;
8687
87- if ( File . Exists ( dotnetScriptPath ) ) {
88+ if ( useCachedInstallScript && File . Exists ( dotnetScriptPath ) ) {
8889 Log . WarningLine ( $ "Using cached installation script found in '{ dotnetScriptPath } '") ;
8990 return true ;
9091 }
92+ Utilities . DeleteFile ( dotnetScriptPath ) ;
9193
9294 Log . StatusLine ( $ " { context . Characters . Link } { dotnetScriptUrl } ", ConsoleColor . White ) ;
9395 await Utilities . Download ( dotnetScriptUrl , tempDotnetScriptPath , DownloadStatus . Empty ) ;
@@ -173,7 +175,7 @@ string[] GetInstallationScriptArgs (string version, string dotnetPath, string do
173175 return args . ToArray ( ) ;
174176 }
175177
176- async Task < bool > InstallDotNetAsync ( Context context , string dotnetPath , string version , bool runtimeOnly = false )
178+ async Task < bool > InstallDotNetAsync ( Context context , string dotnetPath , string version , bool useCachedInstallScript , bool runtimeOnly = false )
177179 {
178180 string cacheDir = context . Properties . GetRequiredValue ( KnownProperties . AndroidToolchainCacheDirectory ) ;
179181
@@ -183,7 +185,7 @@ async Task<bool> InstallDotNetAsync (Context context, string dotnetPath, string
183185 Uri dotnetScriptUrl = Configurables . Urls . DotNetInstallScript ;
184186 string scriptFileName = Path . GetFileName ( dotnetScriptUrl . LocalPath ) ;
185187 string cachedDotnetScriptPath = Path . Combine ( cacheDir , scriptFileName ) ;
186- if ( ! await DownloadDotNetInstallScript ( context , cachedDotnetScriptPath , dotnetScriptUrl ) ) {
188+ if ( ! await DownloadDotNetInstallScript ( context , cachedDotnetScriptPath , dotnetScriptUrl , useCachedInstallScript ) ) {
187189 return false ;
188190 }
189191
0 commit comments