public void Should_pick_unity_csharp_solution_in_folder_mode() { var fs = new MockFileSystem(); fs.File.WriteAllText("Unity.sln", ""); fs.File.WriteAllText("Unity-csharp.sln", ""); var solution = new SolutionPicker(fs).LoadSolution(@".", new Logger(Verbosity.Verbose)); fs.FileInfo.FromFileName (solution.FileName).Name.ShouldEqual("Unity-csharp.sln"); }
static void StartServer( string solutionPath, string clientPathMode, int port, Verbosity verbosity, string configLocation) { var logger = new Logger(verbosity); try { Configuration.ConfigurationLoader.Load( configLocation: configLocation, clientMode: clientPathMode); var solution = new SolutionPicker(new FileSystem()).LoadSolution(solutionPath, logger); logger.Debug("Using solution path " + solutionPath); logger.Debug("Using config file " + configLocation); Console.CancelKeyPress += (sender, e) => { solution.Terminate(); Console.WriteLine("Ctrl-C pressed"); e.Cancel = true; }; var nancyHost = new NancyHost(new Bootstrapper( solution, new NativeFileSystem(), logger), new HostConfiguration { RewriteLocalhost = false }, new Uri("http://localhost:" + port)); nancyHost.Start(); logger.Debug("OmniSharp server is listening"); solution.LoadSolution(); logger.Debug("Solution has finished loading"); while (!solution.Terminated) { Thread.Sleep(1000); } Console.WriteLine("Quit gracefully"); nancyHost.Stop(); } catch (Exception e) { if (e is SocketException || e is HttpListenerException) { logger.Error("Detected an OmniSharp instance already running on port " + port + ". Press a key."); Console.ReadKey(); return; } throw; } }
static void StartServer( string solutionPath, string clientPathMode, int port, Verbosity verbosity, string configLocation, int hostPID) { var logger = new Logger(verbosity); try { Configuration.ConfigurationLoader.Load( configLocation: configLocation, clientMode: clientPathMode); var solution = new SolutionPicker(new FileSystem()).LoadSolution(solutionPath, logger); logger.Debug("Using solution path " + solutionPath); logger.Debug("Using config file " + configLocation); Console.CancelKeyPress += (sender, e) => { solution.Terminate(); Console.WriteLine("Ctrl-C pressed"); e.Cancel = true; }; var nancyHost = new NancyHost(new Bootstrapper( solution, new NativeFileSystem(), logger), new HostConfiguration{ RewriteLocalhost = false }, new Uri("http://localhost:" + port)); nancyHost.Start(); logger.Debug("OmniSharp server is listening"); solution.LoadSolution(); logger.Debug("Solution has finished loading"); if (hostPID != -1) { var hostProcess = Process.GetProcessById(hostPID); hostProcess.EnableRaisingEvents = true; hostProcess.OnExit(() => solution.Terminate()); } while (!solution.Terminated) { Thread.Sleep(1000); } Console.WriteLine("Quit gracefully"); nancyHost.Stop(); } catch (Exception e) { if (e is SocketException || e is HttpListenerException) { logger.Error("Detected an OmniSharp instance already running on port " + port + ". Press a key."); Console.ReadKey(); return; } throw; } }