public void Should_start_in_folder_mode() { var path = Environment.CurrentDirectory + "/Solution/minimal"; var solution = new CSharpFolder(path, new Logger(Verbosity.Verbose)); solution.LoadSolution(); }
static ISolution LoadSolution(string solutionPath, Logger logger) { solutionPath = solutionPath.ApplyPathReplacementsForServer(); ISolution solution; if (Directory.Exists(solutionPath)) { var slnFiles = Directory.GetFiles(solutionPath, "*.sln"); Console.WriteLine(slnFiles.Length); if (slnFiles.Length == 1) { solutionPath = slnFiles[0]; logger.Debug("Found solution file - " + solutionPath); solution = new CSharpSolution(solutionPath, logger); } else { solution = new CSharpFolder(solutionPath, logger); } } else { solution = new CSharpSolution(solutionPath, logger); } return(solution); }
private static void StartServer(string solutionPath, string clientPathMode, int port, Verbosity verbosity) { var logger = new Logger(verbosity); try { Configuration.ConfigurationLoader.Load(clientPathMode); ISolution solution; if (Directory.Exists(solutionPath)) { solution = new CSharpFolder(logger); } else { solution = new CSharpSolution(logger); } 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(solutionPath.ApplyPathReplacementsForServer()); 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; } }