Ejemplo n.º 1
0
        private void DoBatch()
        {
            var logFile   = Path.ChangeExtension(TargetFile, ".log");
            var batchFile = Path.ChangeExtension(TargetFile, ".bat");
            var batch     = "";

            batch += "cd " + '"' + Path.GetDirectoryName(TargetFile) + '"' + "\n";
            foreach (var step in Steps)
            {
                batch += '"' + step.Operation + '"' + ' ' + step.Flags + "\n";
            }
            File.WriteAllText(batchFile, batch);

            var process = new Process
            {
                StartInfo = new ProcessStartInfo(batchFile)
                {
                    WorkingDirectory = Path.GetDirectoryName(TargetFile)
                }
            };

            CompileLogTracer.AddLine("Compile started (not redirected; output in console window)");
            process.Start();
            process.WaitForExit();
            if (File.Exists(logFile))
            {
                using (var fs = new StreamReader(File.Open(logFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
                {
                    var str = fs.ReadToEnd();
                    CompileLogTracer.Add(str);
                }
            }
            CompileLogTracer.AddLine("Compilation complete.");
        }
Ejemplo n.º 2
0
 private void DoRedirected()
 {
     foreach (var step in Steps)
     {
         var process = new Process
         {
             StartInfo = new ProcessStartInfo(step.Operation, step.Flags)
             {
                 CreateNoWindow         = true,
                 UseShellExecute        = false,
                 RedirectStandardOutput = true,
                 WorkingDirectory       = Path.GetDirectoryName(TargetFile)
             }
         };
         process.OutputDataReceived += (sender, args) => CompileLogTracer.AddLine(args.Data);
         process.Start();
         process.BeginOutputReadLine();
         process.WaitForExit();
     }
     CompileLogTracer.AddLine("Compilation complete.");
 }