Esempio n. 1
0
        private void StartServer()
        {
            var path = FileHelpers.GetCsharpProjectFolderPath(_webProjectFolderName);

            var startInfo = new ProcessStartInfo
            {
                WindowStyle = ProcessWindowStyle.Normal,
                ErrorDialog = false,
                CreateNoWindow = false,
                UseShellExecute = false,
                Arguments = string.Format("/path:\"{0}\" /port:{1} /systray:false", path, PortNumber)
            };

            startInfo.SetProjectFlavour(_projectFlavour);
            
            string iisExpress = GetPortableIISExpress();
            
            if (string.IsNullOrEmpty(iisExpress))
            {
                var programfiles = !string.IsNullOrEmpty(startInfo.EnvironmentVariables["programfiles(x86)"])
                                       ? startInfo.EnvironmentVariables["programfiles(x86)"]
                                       : startInfo.EnvironmentVariables["programfiles"];

                iisExpress = programfiles + "\\IIS Express\\iisexpress.exe";
            }

            if (!File.Exists(iisExpress))
            {
                throw new FileNotFoundException(string.Format("Did not find iisexpress.exe at {0}. Ensure that IIS Express is installed to the default location.", iisExpress));
            }

            startInfo.FileName = iisExpress;

            _iisProcess = new Process { StartInfo = startInfo };
            _iisProcess.Start();

            MortalChildProcessList.AddProcess(_iisProcess.Id);
        }