diff --git a/tools/Invoke-Preprocessing.ps1 b/tools/Invoke-Preprocessing.ps1 old mode 100644 new mode 100755 index c9692fc68..19f9adaf9 --- a/tools/Invoke-Preprocessing.ps1 +++ b/tools/Invoke-Preprocessing.ps1 @@ -74,16 +74,17 @@ $count = $ExcludedFiles.Count if ((-NOT ($count -eq 0)) -AND (-NOT $SkipExcludedFilesValidation)) { + $failedFilesList = @() for ($i = 0; $i -lt $count; $i++) { $excludedFile = $ExcludedFiles[$i] - $filePath = "$(($WorkingDir -replace ('\\$', '')) + '\' + ($excludedFile -replace ('\.\\', '')))" - if (-NOT (Get-ChildItem -Recurse -Path "$filePath" -File)) { - $failedFilesList += "'$filePath', " + $filePath = Join-Path $WorkingDir ($excludedFile -replace '^\.\', '') + if (-NOT (Get-Item -Path $filePath -Force -ErrorAction SilentlyContinue)) { + $failedFilesList += "'$filePath'" } } - $failedFilesList = $failedFilesList -replace (',\s*$', '') - if (-NOT $failedFilesList -eq "") { - throw "[Invoke-Preprocessing] One or more File Paths & File Patterns were not found, you can use '-SkipExcludedFilesValidation' switch to skip this check, and the failed files are: $failedFilesList" + if ($failedFilesList.Count -gt 0) { + $failedFilesString = $failedFilesList -join ', ' + throw "[Invoke-Preprocessing] One or more File Paths & File Patterns were not found, you can use '-SkipExcludedFilesValidation' switch to skip this check, and the failed files are: $failedFilesString" } }