I'm having a problem running the compute emulator on a TeamCity agent as part of a CI process doing integration tests with xunit. I'm using the following code to start the emulator and deploy my instances while executing my Xunit tests.
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;
}
The test doesn't work and I have this error in event log:
Application: csmonitor.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: 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) at Microsoft.ServiceHosting.Tools.CloudServicesMonitor.Program.Main(System.String[])
Followed by:
Faulting application name: csmonitor.exe, version: 2.4.6489.1, time stamp: 0x53bdc3cc Faulting module name: KERNELBASE.dll, version: 6.2.9200.16864, time stamp: 0x531d34d8 Exception code: 0xe0434352 Fault offset: 0x0000000000047b8c Faulting process id: 0xe98 Faulting application start time: 0x01cff4c9c18a8431 Faulting application path: C:\Program Files\Microsoft SDKs\Azure\Emulator\csmonitor.exe Faulting module path: C:\Windows\system32\KERNELBASE.dll Report Id: 2321e30b-60bd-11e4-9406-00155dfd9db8 Faulting package full name: Faulting package-relative application ID:
I need to use UseShellExecute = false because I need to redirect and read the output.