@@ -21,7 +21,8 @@ protected override async Task<bool> Execute (Context context)
21
21
var dotnetPath = Configurables . Paths . DotNetPreviewPath ;
22
22
dotnetPath = dotnetPath . TrimEnd ( new char [ ] { Path . DirectorySeparatorChar } ) ;
23
23
24
- if ( ! await InstallDotNetAsync ( context , dotnetPath , BuildToolVersion ) ) {
24
+ if ( ! await InstallDotNetAsync ( context , dotnetPath , BuildToolVersion , useCachedInstallScript : true ) &&
25
+ ! await InstallDotNetAsync ( context , dotnetPath , BuildToolVersion , useCachedInstallScript : false ) ) {
25
26
Log . ErrorLine ( $ "Installation of dotnet SDK '{ BuildToolVersion } ' failed.") ;
26
27
return false ;
27
28
}
@@ -77,17 +78,18 @@ protected override async Task<bool> Execute (Context context)
77
78
return true ;
78
79
}
79
80
80
- async Task < bool > DownloadDotNetInstallScript ( Context context , string dotnetScriptPath , Uri dotnetScriptUrl )
81
+ async Task < bool > DownloadDotNetInstallScript ( Context context , string dotnetScriptPath , Uri dotnetScriptUrl , bool useCachedInstallScript )
81
82
{
82
83
string tempDotnetScriptPath = dotnetScriptPath + "-tmp" ;
83
84
Utilities . DeleteFile ( tempDotnetScriptPath ) ;
84
85
85
86
Log . StatusLine ( "Downloading dotnet-install script..." ) ;
86
87
87
- if ( File . Exists ( dotnetScriptPath ) ) {
88
+ if ( useCachedInstallScript && File . Exists ( dotnetScriptPath ) ) {
88
89
Log . WarningLine ( $ "Using cached installation script found in '{ dotnetScriptPath } '") ;
89
90
return true ;
90
91
}
92
+ Utilities . DeleteFile ( dotnetScriptPath ) ;
91
93
92
94
Log . StatusLine ( $ " { context . Characters . Link } { dotnetScriptUrl } ", ConsoleColor . White ) ;
93
95
await Utilities . Download ( dotnetScriptUrl , tempDotnetScriptPath , DownloadStatus . Empty ) ;
@@ -173,7 +175,7 @@ string[] GetInstallationScriptArgs (string version, string dotnetPath, string do
173
175
return args . ToArray ( ) ;
174
176
}
175
177
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 )
177
179
{
178
180
string cacheDir = context . Properties . GetRequiredValue ( KnownProperties . AndroidToolchainCacheDirectory ) ;
179
181
@@ -183,7 +185,7 @@ async Task<bool> InstallDotNetAsync (Context context, string dotnetPath, string
183
185
Uri dotnetScriptUrl = Configurables . Urls . DotNetInstallScript ;
184
186
string scriptFileName = Path . GetFileName ( dotnetScriptUrl . LocalPath ) ;
185
187
string cachedDotnetScriptPath = Path . Combine ( cacheDir , scriptFileName ) ;
186
- if ( ! await DownloadDotNetInstallScript ( context , cachedDotnetScriptPath , dotnetScriptUrl ) ) {
188
+ if ( ! await DownloadDotNetInstallScript ( context , cachedDotnetScriptPath , dotnetScriptUrl , useCachedInstallScript ) ) {
187
189
return false ;
188
190
}
189
191
0 commit comments