diff --git a/.azure-pipelines/PipelineSteps/test-steps.ps1 b/.azure-pipelines/PipelineSteps/test-steps.ps1 index f435bae3bd2a..cbd27ed996c3 100644 --- a/.azure-pipelines/PipelineSteps/test-steps.ps1 +++ b/.azure-pipelines/PipelineSteps/test-steps.ps1 @@ -31,7 +31,19 @@ if ($PowerShellPlatform) { $preference = $ErrorActionPreference $ErrorActionPreference = 'Continue' $buildProjPath = Join-Path $RepoRoot 'build.proj' -dotnet msbuild $buildProjPath /t:Test "/p:Configuration=$Configuration;TestFramework=$TestFramework" + +$buildArgs = "/p:Configuration=$Configuration;TestFramework=$TestFramework" + +if ($IsLinux) { + # Applying various parallelism/heap restriction behaviors to prevent OOM issues on Ubuntu 24.04 + Write-Host -ForegroundColor Yellow "Detected Linux agent – applying memory tuning for tests" + $env:DOTNET_gcServer = "0" + $env:DOTNET_gcHeapCount = "2" + $buildArgs += ";RunConfiguration.MaxCpuCount=2" +} + +dotnet msbuild $buildProjPath /t:Test $buildArgs + Write-Host -ForegroundColor DarkGreen "-------------------- End testing ... --------------------`n`n`n`n`n" # Test AutoGen Modules With PowerShell Core