|
Listing 3-9 extracted from chapter Build, deploy and configure your .NET applications
Listing 3-8< > Listing 3-10
This listing can be compiled with the command line: csc.exe /out:MyTask.dll /target:library Example_3_9_to_rename_MyTask.cs /r:Microsoft.Build.Framework.dll /r:Microsoft.Build.Utilities.dll Errors: 0 Warnings: 0
Example_3_9_to_rename_MyTask.cs
using System;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace MyTask {
public class MyTouch : Task {
public override bool Execute() {
DateTime now = DateTime.Now;
Log.LogMessage(now.ToString() +
" is now the new date for the following files:");
try {
foreach(string fileName in m_FilesNames) {
Log.LogMessage(" " + fileName);
System.IO.File.SetLastWriteTime(fileName, now);
}
}
catch (Exception ex) {
Log.LogErrorFromException(ex, true);
return false;
}
return true;
}
[Required]
public string[] Files {
get { return (m_FilesNames); } set { m_FilesNames = value; }
}
private string[] m_FilesNames;
}
}
Copyright Patrick Smacchia 2006 2007
|