diff --git a/tests/xharness/TestImporter/Templates/Managed/Resources/src/iOSApp/ViewController.cs b/tests/xharness/TestImporter/Templates/Managed/Resources/src/iOSApp/ViewController.cs index c1ce0e30ed67..7e462928b24f 100644 --- a/tests/xharness/TestImporter/Templates/Managed/Resources/src/iOSApp/ViewController.cs +++ b/tests/xharness/TestImporter/Templates/Managed/Resources/src/iOSApp/ViewController.cs @@ -102,7 +102,7 @@ public async override void ViewDidLoad () break; } if (options.EnableXml) { - runner.WriteResultsToFile (writer, jargon); + runner.WriteResultsToFile (writer ?? Console.Out, jargon); logger.Info ("Xml file was written to the tcp listener."); } else { string resultsFilePath = runner.WriteResultsToFile (jargon); diff --git a/tests/xharness/TestImporter/Templates/Managed/Resources/src/tvOSApp/ViewController.cs b/tests/xharness/TestImporter/Templates/Managed/Resources/src/tvOSApp/ViewController.cs index 6fd0a0a288d1..91be0889a23e 100644 --- a/tests/xharness/TestImporter/Templates/Managed/Resources/src/tvOSApp/ViewController.cs +++ b/tests/xharness/TestImporter/Templates/Managed/Resources/src/tvOSApp/ViewController.cs @@ -64,8 +64,14 @@ public async override void ViewDidLoad () base.ViewDidLoad (); var options = ApplicationOptions.Current; TcpTextWriter writer = null; - if (!string.IsNullOrEmpty (options.HostName)) - writer = new TcpTextWriter (options.HostName, options.HostPort); + if (!string.IsNullOrEmpty (options.HostName)) { + try { + writer = new TcpTextWriter (options.HostName, options.HostPort); + } catch (Exception ex) { + Console.WriteLine ("Network error: Cannot connect to {0}:{1}: {2}. Continuing on console.", options.HostName, options.HostPort, ex); + writer = null; // will default to the console + } + } // we generate the logs in two different ways depending if the generate xml flag was // provided. If it was, we will write the xml file to the tcp writer if present, else @@ -97,7 +103,7 @@ public async override void ViewDidLoad () break; } if (options.EnableXml) { - runner.WriteResultsToFile (writer, jargon); + runner.WriteResultsToFile (writer ?? Console.Out, jargon); logger.Info ("Xml file was written to the tcp listener."); } else { string resultsFilePath = runner.WriteResultsToFile (jargon);