예제 #1
0
        private void Build(Bamboo.VisualStudio.VisualStudio2008.CSharpProject.Models.Project project, string configuration, string projectFolder, string output, string outputFolder, ProjectBuildTracker projectBuildTracker)
        {
            foreach (Bamboo.VisualStudio.VisualStudio2008.CSharpProject.Models.Config config in project.Configs)
            {
                string configName = "";

                if (config.Condition.IndexOf("Debug") != -1)
                {
                    configName = "Debug";
                }
                else if (config.Condition.IndexOf("Release") != -1)
                {
                    configName = "Release";
                }
                else
                {
                    throw new System.Exception("Unknown configuration: " + config.Condition);
                }

                if (configName.ToLower().Equals(configuration.ToLower()))
                {
                    BuildConfig(
                        project.Name,
                        projectFolder,
                        project.ProjectGuid,
                        output,
                        outputFolder,
                        project.Settings,
                        config,
                        project.References,
                        project.ProjectReferences,
                        project.Items,
                        projectBuildTracker);

                    return;
                }
            }

            throw new System.Exception("No project built.");
        }
예제 #2
0
        private void Build(Bamboo.VisualStudio.VisualStudio2008.CSharpProject.Models.Project project, string configuration, string projectFolder, ProjectBuildTracker projectBuildTracker)
        {
            foreach (Bamboo.VisualStudio.VisualStudio2008.CSharpProject.Models.Config config in project.Configs)
            {
                string configName = "";

                if (config.Condition.IndexOf("Debug") != -1)
                {
                    configName = "Debug";
                }
                else if (config.Condition.IndexOf("Release") != -1)
                {
                    configName = "Release";
                }
                else
                {
                    throw new System.Exception("Unknown configuration: " + config.Condition);
                }

                if (configName.ToLower().Equals(configuration.ToLower()))
                {
                    string output = new System.IO.FileInfo(projectFolder).DirectoryName;
                    if (!output.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()))
                    {
                        output += System.IO.Path.DirectorySeparatorChar;
                    }

                    string outputFolder = output;

                    string extension = (project.Settings.OutputType.ToUpper().Equals("EXE") || project.Settings.OutputType.ToUpper().Equals("WINEXE")) ? ".exe" : ".dll";
                    output += config.OutputPath + project.Settings.AssemblyName + extension;

                    this.Build(project, configuration, projectFolder, output, outputFolder, projectBuildTracker);

                    break;
                }
            }
        }
예제 #3
0
        private void Build(Bamboo.VisualStudio.VisualStudio2008.Solution.Models.Solution solution, string configuration, string projectFolder, string output)
        {
            this._projectBuildTracker.Clear();

            System.Collections.Hashtable projectPaths = new System.Collections.Hashtable();

            Bamboo.VisualStudio.ProjectDependencies.ProjectCollection projectsToResolve = new Bamboo.VisualStudio.ProjectDependencies.ProjectCollection();
            foreach (Bamboo.VisualStudio.VisualStudio2008.Solution.Models.Project project in solution.Projects)
            {
                if (project.Path.ToLower().EndsWith(".csproj"))
                {
                    string filename = projectFolder + System.IO.Path.DirectorySeparatorChar + project.Path;

                    System.IO.FileInfo   fileInfo = new System.IO.FileInfo(filename);
                    string               name     = fileInfo.Name.Substring(0, fileInfo.Name.ToLower().LastIndexOf(".csproj"));
                    System.IO.TextReader reader   = fileInfo.OpenText();
                    Bamboo.VisualStudio.VisualStudio2008.CSharpProject.Models.Project csproj2003 = Bamboo.VisualStudio.VisualStudio2008.CSharpProject.ProjectReader.Read(name, reader);
                    reader.Close();


                    projectPaths.Add(csproj2003.ProjectGuid, filename);


                    Bamboo.VisualStudio.ProjectDependencies.Project projectToResolve = new Bamboo.VisualStudio.ProjectDependencies.Project();
                    projectToResolve.Name = csproj2003.Name;
                    projectToResolve.Guid = csproj2003.ProjectGuid;
                    projectToResolve.Tag  = csproj2003;
                    foreach (Bamboo.VisualStudio.VisualStudio2008.CSharpProject.Models.Reference projectReference in csproj2003.References)
                    {
                        if (IsProject(projectReference.Include, solution.Projects))
                        {
                            Bamboo.VisualStudio.ProjectDependencies.ProjectDependency projectDependency = new Bamboo.VisualStudio.ProjectDependencies.ProjectDependency();
                            projectDependency.Name        = projectReference.Include;
                            projectDependency.ProjectGuid = GetProjectGuid(projectReference.Include, solution.Projects);
                            projectToResolve.Dependencies.Add(projectDependency);
                        }
                    }
                    projectsToResolve.Add(projectToResolve);
                }
                else
                {
                    throw new System.Exception("Unsupported project type.");
                }
            }

            Bamboo.VisualStudio.ProjectDependencies.ProjectCollection resolvedProjects = Bamboo.VisualStudio.ProjectDependencies.ProjectDependencyResolver.Resolve(projectsToResolve);


            foreach (Bamboo.VisualStudio.ProjectDependencies.Project project in resolvedProjects)
            {
                if (project.Tag is Bamboo.VisualStudio.VisualStudio2008.CSharpProject.Models.Project)
                {
                    Bamboo.VisualStudio.VisualStudio2008.CSharpProject.Models.Project csproj2003 = (Bamboo.VisualStudio.VisualStudio2008.CSharpProject.Models.Project)project.Tag;

                    string projectPath = projectPaths[csproj2003.ProjectGuid].ToString();

                    if (output.Length == 0)
                    {
                        this._csharpProjectBuilder.Build(projectPath, configuration, this._projectBuildTracker);
                    }
                    else
                    {
                        this._csharpProjectBuilder.Build(projectPath, configuration, output, this._projectBuildTracker);
                    }

                    if (this._csharpProjectBuilder.Succeeded)
                    {
                        this._projectBuildTracker.Add(csproj2003.ProjectGuid, this._csharpProjectBuilder.Assembly);
                    }
                    else
                    {
                        this._succeeded = false;
                        return;
                    }
                }
            }
        }