public void Process()
{
bool perfomedOtherTask = false;
if(m_RemoveDirectories != null && m_RemoveDirectories.Length > 0)
{
try
{
RemoveDirectories(".",m_RemoveDirectories);
}
catch(IOException e)
{
m_Log.Write("Failed to remove directories named {0}",m_RemoveDirectories);
m_Log.WriteException(LogType.Error,e);
}
catch(UnauthorizedAccessException e)
{
m_Log.Write("Failed to remove directories named {0}",m_RemoveDirectories);
m_Log.WriteException(LogType.Error,e);
}
perfomedOtherTask = true;
}
if(m_Target != null && m_Clean != null)
{
m_Log.Write(LogType.Error, "The options /target and /clean cannot be passed together");
return;
}
if(m_Target == null && m_Clean == null)
{
if(perfomedOtherTask) //finished
{
return;
}
m_Log.Write(LogType.Error, "Must pass either /target or /clean to process a Prebuild file");
return;
}
string file = "./prebuild.xml";
if(m_CommandLine.WasPassed("file"))
{
file = m_CommandLine["file"];
}
ProcessFile(file);
string target = (m_Target != null ? m_Target.ToLower() : m_Clean.ToLower());
bool clean = (m_Target == null);
if(clean && target != null && target.Length == 0)
{
target = "all";
}
if(clean && target == "all")//default to all if no target was specified for clean
{
//check if they passed yes
if (!m_CommandLine.WasPassed("yes"))
{
Console.WriteLine("WARNING: This operation will clean ALL project files for all targets, are you sure? (y/n):");
string ret = Console.ReadLine();
if(ret == null)
{
return;
}
ret = ret.Trim().ToLower();
if((ret.ToLower() != "y" && ret.ToLower() != "yes"))
{
return;
}
}
//clean all targets (just cleaning vs2002 target didn't clean nant)
foreach(ITarget targ in m_Targets.Values)
{
targ.Clean(this);
}
}
else
{
if (!m_Targets.ContainsKey(target)) {
m_Log.Write(LogType.Error, "Unknown Target \"{0}\"", target);
return;
}
ITarget targ = m_Targets[target];
if(clean)
{
targ.Clean(this);
}
else
{
targ.Write(this);
}
}
m_Log.Flush();
}