/// <summary> /// Deletes the inf file and optionally the source files /// <param name="includeSourceFiles">If true, the source files will be deleted as well</param> /// </summary> public void Delete(bool includeSourceFiles) { if (includeSourceFiles) { foreach (var sourceFileInfo in SourceFiles) { try { File.Delete(sourceFileInfo.Filename); } catch (IOException) { } } SourceFiles.Clear(); } try { if (!string.IsNullOrEmpty(InfFile)) { File.Delete(InfFile); } } catch (IOException) { } InfFile = null; }
public override void Do() { SourceFiles.Clear(); foreach (var dir in SourceDirectories) { foreach (var file in FileSystemCommands.DirectoryGetFiles(dir)) { SourceFiles.Add(file); } } base.Do(); }
// clear all settings except for referenced assemblies (which are cleared with ClearReferences) public static void Clear() { if (DeleteOutputOnClear) { DeleteOutput(); } CompilerErrors = false; OutputFile = ""; SourceFiles.Clear(); CompilerMessages.Clear(); AllowUnsafe = false; DeleteOutputOnClear = false; }
public void Dispose() => SourceFiles.Clear();
public bool Execute() { bool errors = false; if (string.IsNullOrWhiteSpace(MapBasicExe) || !File.Exists(MapBasicExe)) { Console.Error.WriteLine("MapBasicExe not specified or not found. Path='{0}'", MapBasicExe); return(false); } var startInfo = new System.Diagnostics.ProcessStartInfo { CreateNoWindow = true, UseShellExecute = false, FileName = MapBasicExe, //WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden, Arguments = MapBasicArguments, WorkingDirectory = Path.GetDirectoryName(OutputFolder) ?? throw new InvalidOperationException() }; if (!string.IsNullOrEmpty(ProjectFile)) { // we have a project file, then only compile mbs from it, not from folder SourceFiles.Clear(); // load project file and add modules to list of files to be built // check for existence of .mb file var projectIni = new IniFile(ProjectFile); if (!VerifyMbp(projectIni)) { return(false); } // get application=mbxname foreach (var val in projectIni["Link"]["Module"].Value) { var mb = Path.Combine(OutputFolder, val); mb = Path.ChangeExtension(mb, ".mb"); if (File.Exists(mb)) { SourceFiles.Add(mb); } } } foreach (var item in SourceFiles) { if (item == null) { continue; } startInfo.Arguments += " -d " + item; } if (!string.IsNullOrWhiteSpace(ProjectFile)) { startInfo.Arguments += " -l " + ProjectFile; } try { // Start the process with the info we specified. // Call WaitForExit and then the using statement will close. using (System.Diagnostics.Process exeProcess = System.Diagnostics.Process.Start(startInfo)) { exeProcess?.WaitForExit(); } errors = ProcessErrors(OutputFolder); } catch (Exception) { //TODO: write an error to stderr errors = true; } return(!errors); } // returns true if errors bool ProcessErrors(string folder) { // Put all err file names in current directory. string[] errFiles = Directory.GetFiles(folder, @"*.err"); bool errors = false; foreach (var errFile in errFiles) { using (StreamReader r = new StreamReader(errFile)) { string errLine; while ((errLine = r.ReadLine()) != null) { // sample error: (prospy.mb:72) Found: [End ] while searching for [End Program], [End MapInfo], or [End function]. if (!errLine.StartsWith("(")) { errLine = $"({Path.GetFileNameWithoutExtension(errFile)}.mbp:1)" + errLine; } Console.Error.WriteLine(errLine); errors = true; } } } return(errors); } }
/// <summary> /// Sets or recreate the entire list of input files. /// </summary> /// <param name="fileNames"></param> public void SetSourceFiles(IEnumerable <string> fileNames) { SourceFiles.Clear(); AddSourceFiles(fileNames); }