示例#1
0
文件: Batch.cs 项目: xbloke/sledge
        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.");
        }
示例#2
0
文件: Batch.cs 项目: xbloke/sledge
        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());
            }
        }
示例#3
0
文件: Batch.cs 项目: xbloke/sledge
 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.");
 }
示例#4
0
文件: Batch.cs 项目: 074769/sledge
 private void DoCompile()
 {
     Mediator.Publish(EditorMediator.CompileStarted, this);
     var logger = new CompileLogTracer();
     foreach (var step in Steps)
     {
         var process = new Process
         {
             StartInfo = new ProcessStartInfo(step.Operation, step.Flags)
             {
                 CreateNoWindow = true,
                 UseShellExecute = false,
                 RedirectStandardError = true,
                 RedirectStandardOutput = true,
                 WorkingDirectory = Path.GetDirectoryName(TargetFile)
             }
         };
         process.OutputDataReceived += (sender, args) => logger.AddLine(args.Data);
         process.Start();
         process.BeginOutputReadLine();
         process.WaitForExit();
     }
     var errFile = Path.ChangeExtension(TargetFile, "err");
     if (File.Exists(errFile))
     {
         logger.AddErrorLine("The following errors were detected:\r\n\r\n" + File.ReadAllText(errFile).Trim());
     }
 }