In our psake script , prior to compile we are running check-out assembly files . when compilation task is successfully done the assemblies will be copied then Check-in task will commit the assemblies.
Problem with this approach is if compilation step is stopped the files will be kept checkout.
If the compile task failed then i would like to run another task to undo checkout the files.
task CheckOutFiles -description "Checkout the files" `
-precondition { $OutputFiles -ne $null } `
-action {
foreach( $file in $OutputFiles ) {
exec { Checkout-File -FilePath $file }
}
}
task Compile `
-depends Clean `
-description "Compile the code" `
-requiredVariables solutionFile, buildConfiguration `
{
Write-Host "Building solution $solutionFile" | Out-Null
Assert ( Test-Path $solutionFile ) "SolutionFile $SolutionFile is not found "
Exec { msbuild $SolutionFile "/t:build" "/p:Configuration=$buildConfiguration" }
}
task UndoCheckOutFiles -description "UndoCheckout the files" `
-precondition { $OutputFiles -ne $null } `
-action {
foreach( $file in $OutputFiles ) {
exec { UndoCheckout-File -FilePath $file }
}
}
In compile task ,is there any way that if failed i can run the UndoCheckoutFiles task?