File tree Expand file tree Collapse file tree
.azure-pipelines/common-templates Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3434 displayName : Install AutoRest
3535 inputs :
3636 command : custom
37- customCommand : install -g autorest@latest
37+ customCommand : install -g autorest@3.7.2
3838
3939 - task : Npm@1
4040 displayName : Install AutorestCore
Original file line number Diff line number Diff line change 11# Copyright (c) Microsoft Corporation. All rights reserved.
22# Licensed under the MIT License.
33
4+ function Invoke-WithRetry {
5+ param (
6+ [Parameter (Mandatory = $true )]
7+ [scriptblock ]$ScriptBlock ,
8+
9+ [Parameter (Mandatory = $false )]
10+ [int ]$MaxRetries = 5 ,
11+
12+ [Parameter (Mandatory = $false )]
13+ [int ]$InitialDelayMs = 100 ,
14+
15+ [Parameter (Mandatory = $false )]
16+ [string ]$OperationName = " Operation"
17+ )
18+
19+ for ($attempt = 1 ; $attempt -le $MaxRetries ; $attempt ++ ) {
20+ try {
21+ return & $ScriptBlock
22+ }
23+ catch {
24+ if ($attempt -eq $MaxRetries ) {
25+ Write-Error " $OperationName failed after $MaxRetries attempts. Last error: $_ "
26+ throw
27+ }
28+
29+ $delayMs = $InitialDelayMs * [Math ]::Pow(2 , $attempt - 1 )
30+ Write-Warning " $OperationName failed (attempt $attempt /$MaxRetries ). Retrying in $delayMs ms. Error: $_ "
31+ Start-Sleep - Milliseconds $delayMs
32+ }
33+ }
34+ }
35+
436function Set-CSProjValues (
537 [parameter (Mandatory = $true )][string ] $ModuleCsProj ,
638 [parameter (Mandatory = $true )][string ] $ModuleVersion ,
Original file line number Diff line number Diff line change @@ -92,8 +92,7 @@ $AutoRestTempFolder | ForEach-Object {
9292}
9393
9494$Stopwatch = [system.diagnostics.stopwatch ]::StartNew()
95- $CpuCount = (Get-CimInstance Win32_Processor).NumberOfLogicalProcessors
96- $Throttle = [math ]::Min(4 , $cpuCount / 2 ) # Use half the CPU count but max 4
95+ $Throttle = 2 # Reduced from 4 to prevent file locking issues in parallel module generation
9796$Results = $ModuleToGenerate | ForEach-Object - Parallel {
9897 $Module = $_
9998 Write-Host - ForegroundColor Green " -------------'Generating $Module '-------------"
You can’t perform that action at this time.
0 commit comments