@@ -11,53 +11,72 @@ param(
11
11
[string ]$FeedCred
12
12
)
13
13
14
- $currentDirectory = Get-Location
15
- $random = Get-Random - Maximum 1024
16
-
17
- $env: DOTNET_HOME = Join-Path $currentDirectory " sdk$random "
18
- $env: DOTNET_ROOT = Join-Path $env: DOTNET_HOME $Arch
19
14
$env: DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
20
15
$env: DOTNET_MULTILEVEL_LOOKUP = 0
21
- $env: DOTNET_CLI_HOME = Join-Path $currentDirectory " home$random "
22
- $env: PATH = " $env: DOTNET_ROOT ;$env: PATH ;$env: HELIX_CORRELATION_PAYLOAD \node\bin"
23
16
24
- Write-Host " Set PATH to: $env: PATH "
17
+ $currentDirectory = Get-Location
18
+ $envPath = " $env: PATH ;$env: HELIX_CORRELATION_PAYLOAD \node\bin"
25
19
26
20
function InvokeInstallDotnet ([string ]$command ) {
21
+ Write-Host " InstallDotNet $command "
22
+
23
+ $timeoutSeconds = 180
24
+ $proc = Start-Process - filePath powershell.exe - ArgumentList " -noLogo -NoProfile -ExecutionPolicy unrestricted -command `" $command `" " - NoNewWindow - PassThru
25
+
26
+ $proc | Wait-Process - Timeout $timeoutSeconds
27
+ $exitCode = $proc.ExitCode
28
+
29
+ if ($exitCode -eq 0 ) {
30
+ Write-Host " InstallDotNet $command completed successfully"
31
+ return $true
32
+ }
33
+ elseif ([string ]::IsNullOrWhiteSpace($exitCode )) {
34
+ Write-Warning " InstallDotNet $command timed out after $timeoutSeconds seconds"
35
+ }
36
+ else {
37
+ Write-Warning " InstallDotNet $command failed with exit code $exitCode "
38
+ }
39
+
40
+ $proc | Stop-Process - Force
41
+
42
+ return $false
43
+ }
44
+
45
+ function InstallDotnetSDKAndRuntime ([string ]$Feed , [string ]$FeedCredParam ) {
27
46
foreach ($i in 1 .. 5 ) {
28
- Write-Host " InstallDotNet $command "
47
+ $random = Get-Random - Maximum 1024
48
+ $env: DOTNET_HOME = Join-Path $currentDirectory " sdk$random "
49
+ $env: DOTNET_ROOT = Join-Path $env: DOTNET_HOME $Arch
50
+ $env: DOTNET_CLI_HOME = Join-Path $currentDirectory " home$random "
51
+ $env: PATH = " $env: DOTNET_ROOT ;$envPath "
29
52
30
- $timeoutSeconds = 120
31
- $proc = Start-Process - filePath powershell.exe - ArgumentList " -noLogo -NoProfile -ExecutionPolicy unrestricted -command `" $command `" " - NoNewWindow - PassThru
53
+ Write-Host " Set PATH to: $env: PATH "
32
54
33
- $proc | Wait-Process - Timeout $timeoutSeconds
34
- $exitCode = $proc.ExitCode
55
+ $success = InvokeInstallDotnet " . eng\common\tools.ps1; InstallDotNet $env: DOTNET_ROOT $SdkVersion $Arch `'`' `$ true `' $Feed `' `' $FeedCredParam `' `$ true"
35
56
36
- if ($exitCode -eq 0 ) {
37
- Write-Host " InstallDotNet $command completed successfully "
38
- return
57
+ if (! $success ) {
58
+ Write-Host " Retrying... "
59
+ continue
39
60
}
40
61
41
- if ([ string ]::IsNullOrWhiteSpace( $exitCode )) {
42
- Write-Warning " InstallDotNet $command timed out after $timeoutSeconds seconds retrying... "
43
- }
44
- else {
45
- Write-Warning " InstallDotNet $command failed with exit code $exitCode retrying... "
62
+ $success = InvokeInstallDotnet " . eng\common\tools.ps1; InstallDotNet $ env: DOTNET_ROOT $RuntimeVersion $Arch dotnet `$ true `' $Feed `' `' $FeedCredParam `' `$ true "
63
+
64
+ if ( ! $success ) {
65
+ Write-Host " Retrying... "
66
+ continue
46
67
}
47
68
48
- $proc | Stop-Process - Force
69
+ return
49
70
}
50
71
51
- Write-Warning " InstallDotNet $command exceeded retry limit"
72
+ Write-Error " InstallDotNet $command exceeded retry limit"
52
73
exit 1
53
74
}
54
75
55
- if ($FeedCred -eq $null ) {
56
- InvokeInstallDotnet(" . eng\common\tools.ps1; InstallDotNet $env: DOTNET_ROOT $SdkVersion $Arch `'`' `$ true `'`' `'`' `$ true" )
57
- InvokeInstallDotnet(" . eng\common\tools.ps1; InstallDotNet $env: DOTNET_ROOT $RuntimeVersion $Arch dotnet `$ true `'`' `'`' `$ true" )
76
+ if ([string ]::IsNullOrEmpty($FeedCred )) {
77
+ InstallDotnetSDKAndRuntime
58
78
} else {
59
- InvokeInstallDotnet(" . eng\common\tools.ps1; InstallDotNet $env: DOTNET_ROOT $SdkVersion $Arch `'`' `$ true https://dotnetclimsrc.blob.core.windows.net/dotnet $FeedCred `$ true" )
60
- InvokeInstallDotnet(" . eng\common\tools.ps1; InstallDotNet $env: DOTNET_ROOT $RuntimeVersion $Arch dotnet `$ true https://dotnetclimsrc.blob.core.windows.net/dotnet $FeedCred `$ true" )
79
+ InstallDotnetSDKAndRuntime " https://dotnetclimsrc.blob.core.windows.net/dotnet" $FeedCred
61
80
}
62
81
63
82
Write-Host " Restore: dotnet restore RunTests\RunTests.csproj --ignore-failed-sources"
0 commit comments