Exemplo n.º 1
0
        private async Task FinishOutput(BuildState buildState, JobCompletedEventArgs jobCompletedEventArgs)
        {
            if (buildOutputStream != null)
            {
                await buildOutputStream.FlushAsync();

                buildOutputStream.Flush(flushToDisk: true);
                await buildOutputStream.DisposeAsync();
            }

            int extraChars = outputDecoder.GetCharCount(Array.Empty <byte>(), 0, 0, flush: true);

            if (extraChars > 0)
            {
                var decoded = new char[extraChars];
                outputDecoder.GetChars(Array.Empty <byte>(), 0, 0, decoded, 0, flush: true);
                AppendLineChars(decoded);
            }

            await FileUtil.WriteAllTextToDiskAsync(
                Path.Combine(buildDir, "result.json"),
                JsonConvert.SerializeObject(new JobBuildResult {
                State = buildState,
            }),
                Encoding.UTF8,
                CancellationToken.None
                );

            outputLines.Add(currentLine.ToString());
            OutputLinesChanged?.Invoke(this, new OutputLinesChangedEventArgs(outputLines));

            state = buildState;
            complete.TrySetResult(null);
            JobCompleted?.Invoke(this, jobCompletedEventArgs);
        }
Exemplo n.º 2
0
        private async Task WriteOutput(string s)
        {
            if (outputStreamWriter == null)
            {
                outputStreamWriter = new StreamWriter(new FileStream(Path.Combine(buildDir, "output.log"), FileMode.Create, FileAccess.Write, FileShare.Read, 4096, FileOptions.Asynchronous | FileOptions.SequentialScan));
            }

            await outputStreamWriter.WriteLineAsync(s);

            outputLines.Add(s);
            OutputLinesChanged?.Invoke(this, new OutputLinesChangedEventArgs(outputLines));
        }
Exemplo n.º 3
0
        private void DecodeLines(byte[] statusOutput)
        {
            var decoded = new char[outputDecoder.GetCharCount(statusOutput, 0, statusOutput.Length)];

            outputDecoder.GetChars(statusOutput, 0, statusOutput.Length, decoded, 0);

            bool triggerEvent = AppendLineChars(decoded);

            if (triggerEvent)
            {
                OutputLinesChanged?.Invoke(this, new OutputLinesChangedEventArgs(outputLines));
            }
        }