我在TeamCity代理上运行计算模拟器时遇到问题,作为与xunit进行集成测试的配置项过程的一部分。 我正在使用以下代码来启动模拟器并在执行我的Xunit测试时部署我的实例。在TeamCity代理上运行Azure计算仿真器
ExecuteCsrunWith(serviceDirectory + " " + configurationFile);
private ProcessExecutionResult ExecuteCsrunWith(string argument)
{
var result = new ProcessExecutionResult();
using (var process = new Process())
{
process.StartInfo = new ProcessStartInfo(PathToCsrun, argument)
{
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true
};
process.Start();
result.Output = process.StandardOutput.ReadToEnd();
result.Error = process.StandardError.ReadToEnd();
process.WaitForExit();
Log(result.Output);
Log(result.Error);
}
return result;
}
测试不工作,我有这样的错误在事件日志中:
应用:csmonitor.exe Framework版本:v4.0.30319 说明:该工艺由于终止的未处理的异常。 异常信息:System.InvalidOperationException Stack: at System.Windows.Forms.MessageBox.ShowCore(System.Windows.Forms.IWin32Window,System.String,System.String,System.Windows.Forms.MessageBoxButtons,System.Windows。 Forms.MessageBoxIcon,System.Windows.Forms.MessageBoxDefaultButton,System.Windows.Forms.MessageBoxOptions,Boolean) at System.Windows.Forms.MessageBox.Show(System.String,System.String,System.Windows.Forms.MessageBoxButtons, System.Windows.Forms.MessageBoxIcon) 在Microsoft.ServiceHosting.Tools.CloudServicesMonitor.Program.Main(System.String [])
跟:
错误的应用程序名:csmonitor.exe,版本:2.4.6489.1,时间戳:0x53bdc3cc 错误模块名称:KERNELBASE.dll,版本:6.2.9200.16864,时间戳:0x531d34d8 异常代码:0xe0434352 故障偏移: 0x0000000000047b8c 出错进程ID:0xe98 错误应用程序启动时间:0x01cff4c9c18a8431 错误应用程序路径:C:\ Program Files文件\微软的SDK \ Azure的\模拟器\ csmonitor.exe 错误模块路径:C:\ WINDOWS \ SYSTEM32 \ KERNELBASE.dll 报告ID:2321e30b-60bd-11e4-9406-00155dfd9db8 错误包全名: 错误包相关应用程序ID:
我需要使用UseShellExecute =假,因为我需要重定向和读取输出。