/// <summary> /// Project Finished Event handler, logs to build log file. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void eventSource_ProjectFinishedEvent(object sender, ProjectFinishedEventArgs e) { LogToBuildLog(""); // Print the project file currently building if (e.ProjectFile != null) { string strblanks = ""; for (int i = 0; i < projectfilestack.Count; i++) { if (i - 1 > 0) { strblanks += " "; } } Console.WriteLine("{0}Done Compiling - {1}", strblanks, e.ProjectFile); globalcurrentprojfile = e.ProjectFile; if (String.IsNullOrEmpty(globalcurrentprojfile) == false) { globalcurrentprojfile = PathSW.GetFullPath(globalcurrentprojfile); // Removing current project file that finished from stack. projectfilestack.Pop(); LogToBuildLog("Compiling project file - " + globalcurrentprojfile + " finished."); } } tabcount = 0; this.LogToBuildLog(e, true); }
/// <summary> /// Project Started Event handler, logs to build log file. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void eventSource_ProjectStartedEvent(object sender, ProjectStartedEventArgs e) { // Print the project file currently building if (e.ProjectFile != null) { string strblanks = ""; for (int i = 0; i < projectfilestack.Count; i++) { strblanks += " "; } if (projectfilestack.Count > 0) { Console.WriteLine(); } Console.Write("{0}Compiling - {1} ", strblanks, e.ProjectFile); string currentprojfile = e.ProjectFile; if (String.IsNullOrEmpty(currentprojfile) == false) { currentprojfile = PathSW.GetFullPath(currentprojfile); //Console.WriteLine(Directory.GetCurrentDirectory()); //Console.WriteLine(currentprojfile); // Pushing current project file into stack. projectfilestack.Push(currentprojfile); LogToBuildLog("Current project file - " + currentprojfile); } } tabcount = 0; this.LogToBuildLog(e, true); }
// Todo: Need to improve this to check absolute path, relative path, server and // other paths are not supported. /// <summary> /// Helper method to check if an existing file exists. /// </summary> /// <param name="filename"></param> /// <returns></returns> public static string VerifyFileExists(string filename) { if (String.IsNullOrEmpty(filename)) { return(null); } // Todo: Can cause an Arguement exception need to handle that. string filepath = PathSW.GetFullPath(filename.ToLowerInvariant()); if (!FileSW.Exists(filepath.ToLowerInvariant())) { return(null); } // Todo: First try didn't get anywhere. // Next return(filepath); }
/// <summary> /// Helper method to check if file exists. /// </summary> /// <param name="filename"></param> /// <returns></returns> public static string VerifyFileExists(string filename) { if (filename == null) { return(null); } string filepath = PathSW.GetFullPath(filename.ToLowerInvariant()); if (FileSW.Exists(filepath)) { return(filepath); } if (PathSW.IsPathRooted(filename.ToLowerInvariant()) == true) { string rootpath = PathSW.GetPathRoot(filename); filepath = rootpath + PathSW.DirectorySeparatorChar + PathSW.GetFileName(filename); return(filepath); } // Use additional search paths provided by user. for (int i = 0; _searchpaths != null && i < _searchpaths.Length; i++) { if (String.IsNullOrEmpty(_searchpaths[i]) == false) { filepath = _searchpaths[i] + PathSW.DirectorySeparatorChar + filename; if (FileSW.Exists(filepath)) { return(PathSW.GetFullPath(filepath)); } } } Console.WriteLine("{0} could not be found", filename); return(null); }
/// <summary> /// Enables logging LHCompiler debug info to file. /// </summary> /// <value></value> public static void LogToFile(string write) { if (String.IsNullOrEmpty(logfilename)) { logfilename = @"LHCompiler.log"; } logfilename = PathSW.GetFullPath(logfilename); switch (write) { case "Overwrite": sw = new StreamWriterSW(logfilename); sw.Flush(); break; case "Append": if (FileSW.Exists(logfilename)) { sw = new StreamWriterSW(logfilename, true); } else { sw = new StreamWriterSW(logfilename); sw.Flush(); } break; default: break; } if (sw != null) { sw.Close(); } }