Home
Browse all 647 examples
Download all 647 examples
Download sample chapters
Reviews
Errata
Acknowledgments
Links on .NET
Paradoxal Press

Buy directly from Paradoxal Press at $33.99 (Save 43%)



Category: Programming
Level: Beginner to seasoned
900 pages
ISBN-10 097661322-0
ISBN-13 978-097661322-0
$59.99 USA
$79.99 CANADA


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