Opentk/Source/Build.Tasks/DelTree.cs
the_fiddler dd257ee29d Added Build.Tasks project that contains custom MSBuild tasks for the compilation process:
- DateStamp, which generates a version number based on the current date.
- DelTree which mimics RemoveDir but can delete non-empty directories on xbuild 2.6.x (which only supports empty directories).
- Run which mimics Exec but also captures stderr/stdout.
2010-10-02 22:15:19 +00:00

51 lines
1.3 KiB
C#

using System;
using System.Globalization;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace Build.Tasks
{
/// <summary>
/// Deletes directory and all of its contents.
/// Replaces RemoveDir task which exhibits different behavior
/// on xbuild compared to msbuild: the first requires an empty
/// directory, while the latter does not.
/// </summary>
public class DelTree : Task
{
string path;
/// <summary>
/// The filesystem path to delete.
/// </summary>
[Required]
public string Path
{
get { return path; }
set { path = value; }
}
public override bool Execute()
{
try
{
if (String.IsNullOrEmpty(Path) ||
System.IO.Directory.Exists(Path))
{
return false;
}
else
{
System.IO.Directory.Delete(Path, true);
}
}
catch (Exception e)
{
Log.LogErrorFromException(e);
return false;
}
return true;
}
}
}