public static void EnsureIsRunning(int port, string physicalPath, string virtualPath = null) { var server = new WebDevServer40(port); server.EnsureIsRunning( () => { // Start ASP.NET Development Server var webServerArgs = new StringBuilder(); webServerArgs.AppendFormat("/port:{0} /path:\"{1}\"", port, physicalPath); if (virtualPath != null) { webServerArgs.AppendFormat(" /vpath:{0}", virtualPath); } Debug.WriteLine("Starting {0} {1}", WebDevServer40Path, webServerArgs); Assert.IsNotNull(Process.Start(WebDevServer40Path, webServerArgs.ToString())); }); }
public static void Close(int port) { var server = new WebDevServer40(port); server.CloseIfRunning(); }