Exemple #1
0
        public int Run(string hostname, int port, bool browse)
        {
            string url        = $"http://{hostname}:{port}";
            string serverRoot = Path.Combine(
                ProjectLocator.FindProjectDirectory(),
                ProjectLocator.OutputDirectory
                );

            Directory.CreateDirectory(serverRoot);

            using (var server = new HttpServer(serverRoot, hostname, port))
            {
                server.Start();

                SetupAutoBuildRefresh(server);

                if (browse)
                {
                    RunWebBrowser(url);
                }

                Console.WriteLine("Listening at " + url);
                Console.WriteLine("Press any key to quit.");
                Console.WriteLine();
                Console.ReadKey();
            }
            return(0);
        }
Exemple #2
0
        /// <summary>
        /// Build the project
        /// </summary>
        /// <param name="watch">If true, watch for filesystem changes and rebuild</param>
        /// <param name="silent">If true, don't prompt for user input</param>
        /// <returns></returns>
        public int Run(bool watch, bool silent)
        {
            string projectDirectory = ProjectLocator.FindProjectDirectory();

            Build(projectDirectory);

            if (watch)
            {
                RunFileWatcher(projectDirectory);

                if (!silent)
                {
                    Console.WriteLine("Press any key to quit.");
                    Console.WriteLine();
                    Console.ReadKey();
                }
            }

            return(0);
        }