这两天接完SDK后要出Android包测试,可是使用Jenkins打包的时候总是在某个地方卡住。开始的时候没有在意,就一直中断再重新打,浪费了很多时间,最后发现还是同一个问题,于是就去研究了下打包日志。
研究发现是在通过Process执行Cmd命令行的时候突然中断了,而且中断后没有继续向下执行,封装的部分Process代码如下:
var allOutput = new StringBuilder();
using (var process = new Process())
{
if (workingDirectory != null)
{
process.StartInfo.WorkingDirectory = workingDirectory;
}
process.StartInfo.FileName = cmd;
process.StartInfo.Arguments = preArg + "\"" + command + "\"";
process.StartInfo.UseShellExecute = useShellExecute;
process.StartInfo.ErrorDialog = true;
if (process.StartInfo.UseShellExecute)
{
process.StartInfo.CreateNoWindow = false;
process.StartInfo.RedirectStandardOutput = false;
process.StartInfo.RedirectStandardError = false;
}
else
{
process.StartInfo.CreateNoWindow = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
}
process.Start();
if (!process.StartInfo.UseShellExecute)
{
while (true)
{
var line = process.StandardOutput.ReadLine();
if (line == null)
break;
allOutput.AppendLine(line);
EditorUtility.DisplayProgressBar("[ExecuteCommand] " + command, line, fProgress);
fProgress += .001f;
}
var err = process.StandardError.ReadToEnd();
if (!String.I