Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainForm"/> class.
        /// </summary>
        public MainForm()
        {
            InitializeComponent();

            _buildProcess = new ProjectBuildProcess();
            _buildProcess.BuildCompleted += BuildProcess_BuildCompleted;
            _buildProcess.BuildFinished += BuildProcess_BuildFinished;
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            ParseArguments(args);

            bool showUI = string.IsNullOrWhiteSpace(_bdprojFile) && string.IsNullOrWhiteSpace(_configuration);

            if (showUI)
            {
                Application.EnableVisualStyles();
                using (MainForm form = new MainForm())
                {
                    Console.WriteLine("No options were specified. Starting client window...");
                    form.ShowDialog();
                }
            }
            else
            {
                // Duplicate hacked code to build via console
                string bdprojFile = Path.Combine(Assembly.GetExecutingAssembly().GetWorkingDirectory(), _bdprojFile);
                if (!File.Exists(bdprojFile))
                {
                    return;
                }

                Console.WriteLine("Parsing project file from {0}", bdprojFile);

                ProjectNode project = new ProjectNode();
                project.Parse(bdprojFile);
                BuildConfigurationNode configuration = project.Definitions.SelectMany(def => def.Configurations).FirstOrDefault(c => c.Name == _configuration);
                if (configuration == null)
                {
                    Console.WriteLine("Configuration {0} was not found!", _configuration);
                }

                // Setup build process
                ProjectBuildProcess buildProcess = new ProjectBuildProcess();
                BuildStartArgs buildStartArgs = new BuildStartArgs();
                buildStartArgs.ItemsToBuild = null;

                ManualResetEvent wait = new ManualResetEvent(false);

                buildProcess.BuildCompleted += (o) =>
                {
                    foreach (var item in o.Items)
                    {
                        switch (item.Level)
                        {
                            case BuildInfoItemLevel.Trace:
                                continue;
                            case BuildInfoItemLevel.Info:
                                break;
                            case BuildInfoItemLevel.Warning:
                                Console.ForegroundColor = ConsoleColor.Yellow;
                                break;
                            case BuildInfoItemLevel.Error:
                                Console.ForegroundColor = ConsoleColor.Red;
                                break;
                        }

                        Console.WriteLine(item.Text);
                        Console.ResetColor();
                    }
                };
                buildProcess.BuildFinished += (e) =>
                {
                    wait.Set();
                    buildProcess.SaveBuildLog();
                };

                buildProcess.Start(configuration, buildStartArgs);
                wait.WaitOne();
            }
        }