コード例 #1
0
ファイル: Form1.cs プロジェクト: jaimetsuchiya/ORM
        private void btnBuild_Click(object sender, EventArgs e)
        {
            IProject cmd = (IProject)_projects.Where(t => t.CommandID == cboTemplateProjeto.SelectedItem.ToString()).Single();

            cmd.Load(projectModel);

            if (txtOutputPath.Text == "")
            {
                MessageBox.Show("Favor informar o path de saida");
                txtOutputPath.Focus();
                return;
            }
            try
            {
                cmd.Build(txtOutputPath.Text);
                txtConsole.Text = FormatarConsole(cmd.Mensagens);
            }
            catch (Exception err)
            {
                txtConsole.Text  = FormatarConsole(cmd.Mensagens);
                txtConsole.Text += Environment.NewLine + string.Format("Erro no processamento!Msg: {0}", err.Message);
            }
        }
コード例 #2
0
ファイル: CodeSolution.cs プロジェクト: iniside/CryCIL
        /// <summary>
        /// Builds the solution.
        /// </summary>
        /// <returns>An array of compiled assemblies.</returns>
        public static Assembly[] Build()
        {
            // This is the list of projects to compile.
            List <IProject> buildList = new List <IProject>(CodeSolution.Projects.Count);
            // We gonna organize the list so, projects that depend on other projects are
            // built after them.
            List <IProject> projects = new List <IProject>(CodeSolution.Projects);

            while (projects.Count != 0)
            {
                // Go through the list and put into the build list those who already have
                // their dependencies in the build list.
                for (int i = 0; i < projects.Count; i++)
                {
                    // If project has no extra dependencies, then just put it into the
                    // list.
                    if (projects[i].Dependencies.Length == 0 ||
                        projects[i].Dependencies.All(buildList.Contains))
                    {
                        buildList.Add(projects[i]);
                        projects.RemoveAt(i);
                    }
                }
            }
            // Creates a dictionary where keys are names of projects that were a failure to compile, and values a reasons, why compilation was a failure.
            Dictionary <string, string> failures           = new Dictionary <string, string>(buildList.Count);
            List <Assembly>             compiledAssemblies = new List <Assembly>(buildList.Count);

            while (buildList.Count != 0)
            {
                IProject currentProject = buildList[0];
                buildList.RemoveAt(0);
                if (currentProject.Build() && currentProject.CompiledAssembly != null)
                {
                    compiledAssemblies.Add(currentProject.CompiledAssembly);
                }
                else
                {
                    failures.Add(currentProject.Name,
                                 "Failed to build, check the log for possible errors.");
                    // Consider builds of all projects that depend on this one a failure.
                    IProject[] deps = buildList.Where(x => x.Dependencies.Any(y => y.FileName == currentProject.FileName)).ToArray();
                    for (int i = 0; i < deps.Length; i++)
                    {
                        var dependant = deps[0];
                        buildList.Remove(dependant);
                        failures.Add(dependant.Name,
                                     String.Format("Failed to compile this project, because it depends on failed project {0}", currentProject.Name));
                    }
                }
            }
            if (failures.Count != 0)
            {
                CompilationProblemsReportForm form = new CompilationProblemsReportForm(failures);
                form.ShowDialog();
            }
            // Building is a process that creates a lot of garbage.
            GC.Collect();

            return(compiledAssemblies.ToArray());
        }