Skip to content

Commit 5f6bc30

Browse files
Pin Autorest Version to 3.7.2 (#3547)
* pin autorest version to 3.7.1 * pin to last working version * throttle limit 2 * csProjeHelper with retry
1 parent 2c8b63f commit 5f6bc30

3 files changed

Lines changed: 34 additions & 3 deletions

File tree

.azure-pipelines/common-templates/install-tools.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ steps:
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

tools/CSProjHelper.ps1

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,38 @@
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+
436
function Set-CSProjValues(
537
[parameter(Mandatory = $true)][string] $ModuleCsProj,
638
[parameter(Mandatory = $true)][string] $ModuleVersion,

tools/GenerateModules.ps1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff 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'-------------"

0 commit comments

Comments
 (0)