/// <summary>
        /// Starts a new build. Does nothing if a build is already in process.
        /// </summary>
        /// <param name="configuration">The <see cref="BuildConfiguration"/> representing what configuration to build.</param>
        /// <param name="args">The arguments to use for building.</param>
        public void Start(BuildConfigurationNode configuration, BuildStartArgs args)
        {
            lock (LOCK)
            {
                if (configuration == null)
                {
                    throw new ArgumentNullException("configuration");
                }
                if (args == null)
                {
                    throw new ArgumentNullException("args");
                }

                if (IsRunning)
                {
                    return;
                }

                // Set up build log
                _buildLog = new BuildLog();
                _buildLog.AffectedUser = Environment.UserDomainName;
                _buildLog.BuildStarted = DateTime.UtcNow;

                _buildThread = new Thread(BuildThread);
                _buildThread.Start(new object[2] { configuration, args });
            }
        }
Esempio n. 2
0
        private void tsmBuildProjects_Click(object sender, EventArgs e)
        {
            if (!CanBuild())
            {
                return;
            }

            lsvOutput.Items.Clear();

            BuildStartArgs args = new BuildStartArgs();
            args.ItemsToBuild = new List<string>();
            // TODO
            foreach (BuildItemEntry item in clbBuildItems.CheckedItems)
            {
                args.ItemsToBuild.Add(item.Item.Path);
            }

            _buildProcess.Start((BuildConfigurationNode)trvList.SelectedNode.Tag, args);

            tmrBuildTimer.Start();
        }
Esempio n. 3
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();
            }
        }