Created
April 22, 2014 19:05
-
-
Save jincod/11190655 to your computer and use it in GitHub Desktop.
Refactoring build script on Psake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task Clean { | |
exec -maxRetries 3 { | |
Get-ChildItem . -Include bin,obj,*.orig -Recurse | Remove-Item -Recurse -Force | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task Clean { | |
$iteration = 0 | |
while($iteration++ -lt 10) { | |
$Files = @(Get-ChildItem . -include bin,obj,*.orig -Recurse) | |
$count = $Files.length | |
if ($count -ne 0) { | |
foreach ($File in $Files) { | |
Remove-Item $File -Recurse -Force -EA SilentlyContinue | |
} | |
} | |
else { | |
Write-Host "$iteration - iteration" | |
break | |
} | |
} | |
$files = @(Get-ChildItem . -include bin,obj,*.orig -Recurse) | |
$count = $files.length | |
if ($count -ne 0) { | |
throw "not empty after $iteration iterations, $count - files: $files" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment