diff --git a/src/Platform/Microsoft.Testing.Platform.MSBuild/Tasks/InvokeTestingPlatformTask.cs b/src/Platform/Microsoft.Testing.Platform.MSBuild/Tasks/InvokeTestingPlatformTask.cs index 1422779089..39ed30692f 100644 --- a/src/Platform/Microsoft.Testing.Platform.MSBuild/Tasks/InvokeTestingPlatformTask.cs +++ b/src/Platform/Microsoft.Testing.Platform.MSBuild/Tasks/InvokeTestingPlatformTask.cs @@ -238,7 +238,7 @@ protected override void LogEventsFromTextOutput(string singleLine, MessageImport } protected override void ProcessStarted() - => _connectionLoopTask = Task.Run(() => + => _connectionLoopTask = Task.Run(async () => { try { @@ -249,7 +249,7 @@ protected override void ProcessStarted() pipeServer.RegisterSerializer(new VoidResponseSerializer(), typeof(VoidResponse)); pipeServer.RegisterSerializer(new FailedTestInfoRequestSerializer(), typeof(FailedTestInfoRequest)); pipeServer.RegisterSerializer(new RunSummaryInfoRequestSerializer(), typeof(RunSummaryInfoRequest)); - pipeServer.WaitConnectionAsync(_waitForConnections.Token).GetAwaiter().GetResult(); + await pipeServer.WaitConnectionAsync(_waitForConnections.Token); _connections.Add(pipeServer); Log.LogMessage(MessageImportance.Low, $"Client connected to '{_pipeNameDescription.Name}'"); } @@ -258,6 +258,10 @@ protected override void ProcessStarted() { // Do nothing we're cancelling } + catch (Exception ex) + { + Log.LogError(ex.ToString()); + } }); public override bool Execute() diff --git a/src/Platform/Microsoft.Testing.Platform/IPC/NamedPipeServer.cs b/src/Platform/Microsoft.Testing.Platform/IPC/NamedPipeServer.cs index 1eb2eb56f4..5625a972d8 100644 --- a/src/Platform/Microsoft.Testing.Platform/IPC/NamedPipeServer.cs +++ b/src/Platform/Microsoft.Testing.Platform/IPC/NamedPipeServer.cs @@ -63,7 +63,7 @@ public NamedPipeServer( CancellationToken cancellationToken) { ArgumentGuard.IsNotNull(pipeNameDescription); - _namedPipeServerStream = new((PipeName = pipeNameDescription).Name, PipeDirection.InOut, maxNumberOfServerInstances); + _namedPipeServerStream = new((PipeName = pipeNameDescription).Name, PipeDirection.InOut, maxNumberOfServerInstances, PipeTransmissionMode.Byte, PipeOptions.Asynchronous); _callback = callback; _environment = environment; _logger = logger;