Esempio 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.");
        }
Esempio n. 2
0
        private void DoCompile()
        {
            Mediator.Publish(EditorMediator.CompileStarted, this);

            if (Build.DontRedirectOutput)
            {
                DoBatch();
            }
            else
            {
                DoRedirected();
            }

            var errFile = Path.ChangeExtension(TargetFile, "err");

            if (File.Exists(errFile))
            {
                CompileLogTracer.AddErrorLine("The following errors were detected:\r\n\r\n" + File.ReadAllText(errFile).Trim());
            }
        }
Esempio n. 3
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.");
 }