@@ -195,27 +195,38 @@ function Invoke-WithFileLockRetry {
195195function Remove-StaleObjFolders {
196196 <#
197197 . SYNOPSIS
198- Removes stale per-project obj/ folders from Src/ .
198+ Removes stale per-project obj/ folders from source trees .
199199 . DESCRIPTION
200200 Since SDK migration, intermediate output uses centralized Obj/ folder.
201201 Old per-project obj/ folders cause CS0579 duplicate attribute errors.
202202 #>
203203 param ([Parameter (Mandatory )][string ]$RepoRoot )
204204
205- $srcPath = Join-Path $RepoRoot " Src"
206- try {
207- # Use .NET enumeration for performance (faster than Get-ChildItem -Recurse)
208- $staleObjFolders = [System.IO.Directory ]::GetDirectories($srcPath , " obj" , [System.IO.SearchOption ]::AllDirectories)
209- if ($staleObjFolders.Length -gt 0 ) {
210- Write-Host " Removing stale per-project obj/ folders ($ ( $staleObjFolders.Length ) found)..." - ForegroundColor Yellow
211- foreach ($folder in $staleObjFolders ) {
212- Remove-Item - Path $folder - Recurse - Force - ErrorAction SilentlyContinue
205+ $scanRoots = @ (
206+ (Join-Path $RepoRoot " Src" ),
207+ (Join-Path $RepoRoot " Lib" ),
208+ (Join-Path $RepoRoot " FLExInstaller" )
209+ )
210+
211+ foreach ($root in $scanRoots ) {
212+ if (-not (Test-Path $root - PathType Container)) {
213+ continue
214+ }
215+
216+ try {
217+ # Use .NET enumeration for performance (faster than Get-ChildItem -Recurse)
218+ $staleObjFolders = [System.IO.Directory ]::GetDirectories($root , " obj" , [System.IO.SearchOption ]::AllDirectories)
219+ if ($staleObjFolders.Length -gt 0 ) {
220+ Write-Host " Removing stale per-project obj/ folders under '$root ' ($ ( $staleObjFolders.Length ) found)..." - ForegroundColor Yellow
221+ foreach ($folder in $staleObjFolders ) {
222+ Remove-Item - Path $folder - Recurse - Force - ErrorAction SilentlyContinue
223+ }
224+ Write-Host " [OK] Stale obj/ folders cleaned under '$root '" - ForegroundColor Green
213225 }
214- Write-Host " [OK] Stale obj/ folders cleaned" - ForegroundColor Green
215226 }
216- }
217- catch {
218- # Ignore enumeration errors (access denied, etc.)
227+ catch {
228+ # Ignore enumeration errors (access denied, etc.)
229+ }
219230 }
220231
221232 # Check for stale Output/Common/ (pre-configuration-aware build artifacts)
0 commit comments