Exemple #1
0
        public DthTestServer(ILoggerFactory loggerFactory)
        {
            LoggerFactory = loggerFactory;

            Port = FindFreePort();
            HostId = Guid.NewGuid().ToString();

            _program = new ProjectModelServerCommand(Port, HostId, LoggerFactory);

            _thread = new Thread(() => { _program.OpenChannel(); }) { IsBackground = true };
            _thread.Start();
        }
Exemple #2
0
        public static int Run(string[] args)
        {
            var app = new CommandLineApplication();

            app.Name        = "dotnet-projectmodel-server";
            app.Description = ".NET Project Model Server";
            app.FullName    = ".NET Design Time Server";
            app.Description = ".NET Design Time Server";
            app.HelpOption("-?|-h|--help");

            var verbose  = app.Option("--verbose", "Verbose ouput", CommandOptionType.NoValue);
            var hostpid  = app.Option("--host-pid", "The process id of the host", CommandOptionType.SingleValue);
            var hostname = app.Option("--host-name", "The name of the host", CommandOptionType.SingleValue);
            var port     = app.Option("--port", "The TCP port used for communication", CommandOptionType.SingleValue);

            app.OnExecute(() =>
            {
                try
                {
                    if (!MonitorHostProcess(hostpid))
                    {
                        return(1);
                    }

                    var intPort = CheckPort(port);
                    if (intPort == -1)
                    {
                        return(1);
                    }

                    if (!hostname.HasValue())
                    {
                        Reporter.Error.WriteLine($"Option \"{hostname.LongName}\" is missing.");
                        return(1);
                    }

                    var program = new ProjectModelServerCommand(intPort, hostname.Value());
                    program.OpenChannel();
                }
                catch (Exception ex)
                {
                    Reporter.Error.WriteLine($"Unhandled exception in server main: {ex}");
                    throw;
                }

                return(0);
            });

            return(app.Execute(args));
        }
Exemple #3
0
        public static int Run(string[] args)
        {
            var app = new CommandLineApplication();
            app.Name = "dotnet-projectmodel-server";
            app.Description = ".NET Project Model Server";
            app.FullName = ".NET Design Time Server";
            app.Description = ".NET Design Time Server";
            app.HelpOption("-?|-h|--help");

            var verbose = app.Option("--verbose", "Verbose ouput", CommandOptionType.NoValue);
            var hostpid = app.Option("--host-pid", "The process id of the host", CommandOptionType.SingleValue);
            var hostname = app.Option("--host-name", "The name of the host", CommandOptionType.SingleValue);
            var port = app.Option("--port", "The TCP port used for communication", CommandOptionType.SingleValue);

            app.OnExecute(() =>
            {
                try
                {
                    if (!MonitorHostProcess(hostpid))
                    {
                        return 1;
                    }

                    var intPort = CheckPort(port);
                    if (intPort == -1)
                    {
                        return 1;
                    }

                    if (!hostname.HasValue())
                    {
                        Reporter.Error.WriteLine($"Option \"{hostname.LongName}\" is missing.");
                        return 1;
                    }

                    var program = new ProjectModelServerCommand(intPort, hostname.Value());
                    program.OpenChannel();
                }
                catch (Exception ex)
                {
                    Reporter.Error.WriteLine($"Unhandled exception in server main: {ex}");
                    throw;
                }

                return 0;
            });

            return app.Execute(args);
        }
Exemple #4
0
        public static int Run(string[] args)
        {
            var app = new CommandLineApplication();

            app.Name        = "dotnet-projectmodel-server";
            app.Description = ".NET Project Model Server";
            app.FullName    = ".NET Design Time Server";
            app.Description = ".NET Design Time Server";
            app.HelpOption("-?|-h|--help");

            var verbose  = app.Option("--verbose", "Verbose ouput", CommandOptionType.NoValue);
            var hostpid  = app.Option("--host-pid", "The process id of the host", CommandOptionType.SingleValue);
            var hostname = app.Option("--host-name", "The name of the host", CommandOptionType.SingleValue);
            var port     = app.Option("--port", "The TCP port used for communication", CommandOptionType.SingleValue);

            app.OnExecute(() =>
            {
                var loggerFactory = new LoggerFactory();
                loggerFactory.AddConsole(verbose.HasValue() ? LogLevel.Debug : LogLevel.Information);

                var logger = loggerFactory.CreateLogger <ProjectModelServerCommand>();

                if (!MonitorHostProcess(hostpid, logger))
                {
                    return(1);
                }

                var intPort = CheckPort(port, logger);
                if (intPort == -1)
                {
                    return(1);
                }

                if (!hostname.HasValue())
                {
                    logger.LogError($"Option \"{hostname.LongName}\" is missing.");
                    return(1);
                }

                var program = new ProjectModelServerCommand(intPort, hostname.Value(), loggerFactory);
                program.OpenChannel();

                return(0);
            });

            return(app.Execute(args));
        }
Exemple #5
0
        public static int Run(string[] args)
        {
            var app = new CommandLineApplication();
            app.Name = "dotnet-projectmodel-server";
            app.Description = ".NET Project Model Server";
            app.FullName = ".NET Design Time Server";
            app.Description = ".NET Design Time Server";
            app.HelpOption("-?|-h|--help");

            var verbose = app.Option("--verbose", "Verbose ouput", CommandOptionType.NoValue);
            var hostpid = app.Option("--host-pid", "The process id of the host", CommandOptionType.SingleValue);
            var hostname = app.Option("--host-name", "The name of the host", CommandOptionType.SingleValue);
            var port = app.Option("--port", "The TCP port used for communication", CommandOptionType.SingleValue);

            app.OnExecute(() =>
            {
                var loggerFactory = new LoggerFactory();
                loggerFactory.AddConsole(verbose.HasValue() ? LogLevel.Debug : LogLevel.Information);

                var logger = loggerFactory.CreateLogger<ProjectModelServerCommand>();

                if (!MonitorHostProcess(hostpid, logger))
                {
                    return 1;
                }

                var intPort = CheckPort(port, logger);
                if (intPort == -1)
                {
                    return 1;
                }

                if (!hostname.HasValue())
                {
                    logger.LogError($"Option \"{hostname.LongName}\" is missing.");
                    return 1;
                }

                var program = new ProjectModelServerCommand(intPort, hostname.Value(), loggerFactory);
                program.OpenChannel();

                return 0;
            });

            return app.Execute(args);
        }