Пример #1
0
        private int Run(string[] args)
        {
            _output = new ConsoleOutput();

            try
            {
                BuildOptions options = ParseBuildOptions(args);
                if (options == null || options.Solution == null)
                {
                    return(1);
                }

                GlobalSettings globalSettings = GlobalSettings.Load(_output);
                globalSettings.Save();
                var settings = new Settings(globalSettings, options, _output);

                var stopwatch = new Stopwatch();
                stopwatch.Start();

                int exitCode = 0;
                if (options.CleanCache)
                {
                    CacheCleaner.Run(settings);
                }
                else
                {
                    var          solutionReaderWriter = new SolutionReaderWriter(settings);
                    SolutionInfo solutionInfo         = solutionReaderWriter.ReadWrite(options.Solution.FullName);
                    settings.SolutionSettings = SolutionSettings.Load(settings, solutionInfo);
                    var projectReaderWriter = new ProjectReaderWriter(settings);
                    projectReaderWriter.ReadWrite(solutionInfo);
                    settings.SolutionSettings.UpdateAndSave(settings, solutionInfo);

                    if (!options.GenerateOnly)
                    {
                        var processLauncher = new ProcessLauncher(settings);
                        Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs cancelArgs)
                        {
                            _output.WriteLine("Stopping build...");
                            processLauncher.Stop();
                            cancelArgs.Cancel = true;
                        };

                        exitCode = processLauncher.Run(solutionInfo);
                    }
                }

                stopwatch.Stop();
                TimeSpan ts            = stopwatch.Elapsed;
                string   buildTimeText = string.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);
                _output.WriteLine("Build time: " + buildTimeText);

                return(exitCode);
            }
            catch (Exception e)
            {
                _output.WriteLine("ERROR: " + e.Message);
                return(-1);
            }
        }
Пример #2
0
        private void BuildThread(Settings settings)
        {
            _output.Clear();
            _output.Activate();
            _output.WriteLine("RudeBuild building...");
            _output.WriteLine();

            _stopwatch.Reset();
            _stopwatch.Start();

            int exitCode = -1;

            try
            {
                var          solutionReaderWriter = new SolutionReaderWriter(settings);
                SolutionInfo solutionInfo         = solutionReaderWriter.ReadWrite(settings.BuildOptions.Solution.FullName);
                settings.SolutionSettings = SolutionSettings.Load(settings, solutionInfo);
                var projectReaderWriter = new ProjectReaderWriter(settings);
                projectReaderWriter.ReadWrite(solutionInfo);
                settings.SolutionSettings.UpdateAndSave(settings, solutionInfo);

                exitCode = _processLauncher.Run(solutionInfo);
            }
            catch (System.Exception ex)
            {
                _output.WriteLine("Build failed. An error occurred while building:");
                _output.WriteLine(ex.Message);
            }

            _stopwatch.Stop();
            TimeSpan ts            = _stopwatch.Elapsed;
            string   buildTimeText = string.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);

            _output.WriteLine("Build time: " + buildTimeText);

            lock (_lock)
            {
                _lastBuildWasSuccessful = !_isBeingStopped && exitCode == 0;
                _buildThread            = null;
                _processLauncher        = null;
            }
        }