private void tsmProjectLoad_Click(object sender, EventArgs e) { using (OpenFileDialog dialog = new OpenFileDialog()) { dialog.Filter = "Project files (*.bdproj)|*.bdproj"; dialog.InitialDirectory = Assembly.GetExecutingAssembly().GetWorkingDirectory(); if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { _project = new ProjectNode(); _project.Parse(dialog.FileName); // build treeview trvList.Nodes["ROOT"].Nodes.Clear(); TreeNode tnProject = new TreeNode("Project [ '" + _project.Type + "' ]"); tnProject.Tag = _project; tnProject.ForeColor = Color.Gray; foreach (BuildDefinitionNode def in _project.Definitions) { TreeNode tnDefinition = new TreeNode(def.Name); tnDefinition.ToolTipText = def.Description; tnDefinition.Tag = def; tnDefinition.ForeColor = Color.Gray; foreach (BuildConfigurationNode conf in def.Configurations) { TreeNode tnConfiguration = new TreeNode(conf.Name + " [ '" + conf.Configuration + "' ]"); tnConfiguration.Tag = conf; tnDefinition.Nodes.Add(tnConfiguration); } tnProject.Nodes.Add(tnDefinition); } trvList.Nodes["ROOT"].Nodes.Add(tnProject); trvList.ExpandAll(); } } }
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(); } }