MessagePack.UnityEditor CodeGen Missing log information
Opened this issue · 0 comments
eefan000 commented
I changed it to use OutputDataReceived to receive and store all logs.
MessagePack.Unity.Editor.ProcessHelper.InvokeProcessStartAsync
public static Task<string> InvokeProcessStartAsync(string fileName, string arguments)
{
var psi = new ProcessStartInfo()
{
CreateNoWindow = true,
StandardOutputEncoding = Encoding.UTF8,
StandardErrorEncoding = Encoding.UTF8,
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
FileName = fileName,
Arguments = arguments,
WorkingDirectory = Application.dataPath
};
Process p;
var log = new StringBuilder();
try
{
p = Process.Start(psi);
p.OutputDataReceived += (object sender, DataReceivedEventArgs e) =>
{
if (e.Data != null)
{
log.AppendLine(e.Data);
}
};
}
catch (Exception ex)
{
return Task.FromException<string>(ex);
}
var tcs = new TaskCompletionSource<string>();
p.EnableRaisingEvents = true;
p.Exited += (object sender, System.EventArgs e) =>
{
p.Dispose();
p = null;
tcs.TrySetResult(log.ToString());
};
return tcs.Task;
}