File tree Expand file tree Collapse file tree 3 files changed +32
-11
lines changed Expand file tree Collapse file tree 3 files changed +32
-11
lines changed Original file line number Diff line number Diff line change @@ -86,14 +86,38 @@ function Invoke-RestMethodWithRetry {
8686function Invoke-ValidateCommand {
8787 param (
8888 [Parameter (Mandatory )]
89- [string ]$Command
89+ [string ]$Command ,
90+ [Uint ] $Timeout = 0
9091 )
9192
92- $output = Invoke-Expression - Command $Command
93- if ($LASTEXITCODE -ne 0 ) {
94- throw " Command '$Command ' has finished with exit code $LASTEXITCODE "
93+ if ($Timeout -eq 0 )
94+ {
95+ $output = Invoke-Expression - Command $Command
96+ if ($LASTEXITCODE -ne 0 ) {
97+ throw " Command '$Command ' has finished with exit code $LASTEXITCODE "
98+ }
99+ return $output
100+ }
101+ else
102+ {
103+ $job = $command | Start-Job - ScriptBlock {
104+ $output = Invoke-Expression - Command $input
105+ if ($LASTEXITCODE -ne 0 ) {
106+ throw ' Command failed'
107+ }
108+ return $output
109+ }
110+ $waitObject = $job | Wait-Job - Timeout $Timeout
111+ if (-not $waitObject )
112+ {
113+ throw " Command '$Command ' has timed out"
114+ }
115+ if ($waitObject.State -eq ' Failed' )
116+ {
117+ throw " Command '$Command ' has failed"
118+ }
119+ Receive-Job - Job $job
95120 }
96- return $output
97121}
98122
99123function Start-DownloadWithRetry {
Original file line number Diff line number Diff line change @@ -129,10 +129,7 @@ function Approve-XcodeLicense {
129129 $XcodeRootPath = Get-XcodeRootPath - Version $Version
130130 Write-Host " Approving Xcode license for '$XcodeRootPath '..."
131131 $xcodeBuildPath = Get-XcodeToolPath - XcodeRootPath $XcodeRootPath - ToolName " xcodebuild"
132- try {
133- Invoke-Expression - Command " sudo $xcodeBuildPath -license accept" 2>&1 | Out-Null
134- } catch { }
135-
132+ Invoke-ValidateCommand - Command " sudo $xcodeBuildPath -license accept" - Timeout 15
136133}
137134
138135function Install-XcodeAdditionalPackages {
Original file line number Diff line number Diff line change 33 "default" : " 14.2" ,
44 "x64" : {
55 "versions" : [
6- { "link" : " 15.0" , "version" : " 15.0.0-Beta.5+15A5209g " },
6+ { "link" : " 15.0" , "version" : " 15.0.0-Beta.6+15A5219j " },
77 { "link" : " 14.3.1" , "version" : " 14.3.1+14E300c" },
88 { "link" : " 14.3" , "version" : " 14.3.0+14E222b" },
99 { "link" : " 14.2" , "version" : " 14.2.0+14C18" },
1212 },
1313 "arm64" :{
1414 "versions" : [
15- { "link" : " 15.0" , "version" : " 15.0.0-Beta.5+15A5209g " },
15+ { "link" : " 15.0" , "version" : " 15.0.0-Beta.6+15A5219j " },
1616 { "link" : " 14.3.1" , "version" : " 14.3.1+14E300c" },
1717 { "link" : " 14.3" , "version" : " 14.3.0+14E222b" },
1818 { "link" : " 14.2" , "version" : " 14.2.0+14C18" },
You can’t perform that action at this time.
0 commit comments