コード例 #1
0
ファイル: Batch.cs プロジェクト: NCC-Lykos/Chisel
        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 プロジェクト: NCC-Lykos/Chisel
        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 プロジェクト: NCC-Lykos/Chisel
 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.");
 }