diff --git a/src/Microsoft.AspNetCore.Server.IntegrationTesting/Common/PortHelper.cs b/src/Microsoft.AspNetCore.Server.IntegrationTesting/Common/PortHelper.cs deleted file mode 100644 index 805a590180..0000000000 --- a/src/Microsoft.AspNetCore.Server.IntegrationTesting/Common/PortHelper.cs +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Diagnostics; -using System.Runtime.InteropServices; -using Microsoft.Extensions.Logging; - -namespace Microsoft.AspNetCore.Server.IntegrationTesting -{ - public class PortHelper - { - public static void LogPortStatus(ILogger logger, int port) - { - logger.LogInformation("Checking for processes currently using port {0}", port); - - var psi = new ProcessStartInfo - { - RedirectStandardOutput = true, - RedirectStandardError = true, - }; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - psi.FileName = "cmd"; - psi.Arguments = $"/C netstat -nq | find \"{port}\""; - } - else - { - psi.FileName = "lsof"; - psi.Arguments = $"-i :{port}"; - } - - var process = new Process - { - StartInfo = psi, - EnableRaisingEvents = true - }; - - var linesLogged = false; - - process.OutputDataReceived += (sender, data) => - { - if (!string.IsNullOrWhiteSpace(data.Data)) - { - linesLogged = true; - logger.LogInformation("portstatus: {0}", data.Data); - } - }; - process.ErrorDataReceived += (sender, data) => - { - if (!string.IsNullOrWhiteSpace(data.Data)) - { - logger.LogWarning("portstatus: {0}", data.Data); - } - }; - - try - { - process.Start(); - process.BeginErrorReadLine(); - process.BeginOutputReadLine(); - process.WaitForExit(); - - if (!linesLogged) - { - logger.LogInformation("portstatus: it appears the port {0} is not in use.", port); - } - } - catch (Exception ex) - { - logger.LogWarning("Failed to check port status. Executed: {0} {1}\nError: {2}", psi.FileName, psi.Arguments, ex.ToString()); - } - return; - } - } -} diff --git a/src/Microsoft.AspNetCore.Server.IntegrationTesting/Deployers/SelfHostDeployer.cs b/src/Microsoft.AspNetCore.Server.IntegrationTesting/Deployers/SelfHostDeployer.cs index 83ec0806c0..31a7023cfb 100644 --- a/src/Microsoft.AspNetCore.Server.IntegrationTesting/Deployers/SelfHostDeployer.cs +++ b/src/Microsoft.AspNetCore.Server.IntegrationTesting/Deployers/SelfHostDeployer.cs @@ -83,12 +83,6 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting executableArgs = $"run --framework {targetFramework} {DotnetArgumentSeparator}"; } - if (uri.Port != 0) - { - // shows output from netstat/lsof. May be useful if the port is already in use - PortHelper.LogPortStatus(Logger, uri.Port); - } - executableArgs += $" --server.urls {uri} " + $" --server {(DeploymentParameters.ServerType == ServerType.WebListener ? "Microsoft.AspNetCore.Server.HttpSys" : "Microsoft.AspNetCore.Server.Kestrel")}"; @@ -154,4 +148,4 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting StopTimer(); } } -} +} \ No newline at end of file