Beispiel #1
0
        public bool Start()
        {
            if (_started)
            {
                return(false);
            }
            _started = true;

            DeleporterUtilities.SetWebAndRemotingPortsBasedOnAvailability();

            if (!DeleporterUtilities.LocalPortIsAvailable(DeleporterConfiguration.WebHostPort))
            {
                LoggerClient.Log("ERROR: IIS Express port {0} is being used. Attempt to start IIS Express has been aborted",
                                 DeleporterConfiguration.WebHostPort);
                return(false);
            }

            var fileName = FileUtilities.TryToFindProgramFile("iisexpress.exe", "IIS Express");

            if (fileName == null)
            {
                throw new FileNotFoundException("IIS Express was not found on this machine.");
            }

            _iisExpressProcess = new Process
            {
                StartInfo =
                {
                    FileName  = fileName,
                    Arguments =
                        "/path:\"" + DeleporterConfiguration.FullyQualifiedPathToWebApp + "\" /port:"
                        + DeleporterConfiguration.WebHostPort + " /trace:error",
                    WindowStyle     = ProcessWindowStyle.Hidden,
                    UseShellExecute = false,
                    CreateNoWindow  = true,
                }
            };

            LoggerClient.Log("IIS Express starting on port {0} using path {1}... ", DeleporterConfiguration.WebHostPort, DeleporterConfiguration.FullyQualifiedPathToWebApp);
            try {
                _iisExpressProcess.Start();
            } catch (SocketException ex) {
                LoggerClient.Log("Couldn't start IIS Express ...  {0}", ex.Message);
                return(false);
            }

            DeleporterUtilities.WaitForLocalPortToBecomeUnavailable(DeleporterConfiguration.WebHostPort);
            DeleporterUtilities.PrimeServerHomepage();
            LoggerClient.Log("IIS Express Started");
            return(true);
        }
Beispiel #2
0
        public bool Start()
        {
            if (_started)
            {
                return(false);
            }
            _started = true;

            DeleporterUtilities.SetWebAndRemotingPortsBasedOnAvailability();

            if (!DeleporterUtilities.LocalPortIsAvailable(DeleporterConfiguration.WebHostPort))
            {
                LoggerClient.Log("ERROR: Cassini port {0} is being used. Attempt to start Cassini has been aborted",
                                 DeleporterConfiguration.WebHostPort);
                throw new InvalidOperationException(string.Format("Cassini port {0} is being used by something else. Attempt to start Cassini has been aborted",
                                                                  DeleporterConfiguration.WebHostPort));
            }

            LoggerClient.Log("Using web.config location {0} with port {1}",
                             DeleporterConfiguration.FullyQualifiedPathToWebApp, DeleporterConfiguration.WebHostPort);

            _casinniServer = new Microsoft.VisualStudio.WebHost.Server(DeleporterConfiguration.WebHostPort, "/",
                                                                       DeleporterConfiguration.FullyQualifiedPathToWebApp);

            LoggerClient.Log("Cassini starting on port {0} using path {1}... ", DeleporterConfiguration.WebHostPort, DeleporterConfiguration.FullyQualifiedPathToWebApp);
            try {
                _casinniServer.Start();
            } catch (Exception ex) {
                LoggerClient.Log("Couldn't start Cassini ... {0}", ex.Message);
                return(false);
            }

            DeleporterUtilities.WaitForLocalPortToBecomeUnavailable(DeleporterConfiguration.WebHostPort);
            LoggerClient.Log("Cassini Started");
            DeleporterUtilities.PrimeServerHomepage();
            return(true);
        }