I'm trying to delete a directory (3gb) after a TFSBuild finishes. I put the task in a try finally block so that it always executes. Problem is when a build is manually stopped, the task is killed if it takes >1 min or so. TFSBuild thinks that the build is hanging because it's taking so long to stop.
I've tried the following to no avail:
static void Main(string[] args)
{
ThreadPool.QueueUserWorkItem(s => DeleteDir(@"C:\292\Sources\", @"C:\testdel\del.bat"));
}
static void DeleteDir(string path, string batchDir)
{
var process = new Process
{
StartInfo =
{
Arguments = string.Format("{0}",
path)
}
};
process.StartInfo.FileName = batchDir;
process.Start();
}
}
Here is the contents of the batch file:
del %1 /f /s /Q
I've also tried with Directory.Delete etc.
TFSBuild executes the task and then stops the build, but the delete task does not complete. If I don't call it async, then it just kills the delete task after ~1 min.
How do I get this delete task to execute after the parent process is killed?