Example #1
0
        /// <summary>
        /// Builds the repositories that have been recently updated.
        /// </summary>
        /// <returns>
        ///   <c>true</c> if all repositories were built successfully; <c>false</c> if at least one repository failed to build.
        /// </returns>
        /// <seealso cref="UpdateRepositories" />
        ///   <seealso cref="RepositoriesToBuild" />
        ///   <seealso cref="RepositoriesToDeploy" />
        /// <remarks>
        /// This method will not update the local repositories from their remote origins. To do so, call <see cref="UpdateRepositories" />.
        /// The list of repositories that will be built by this method is available through <see cref="RepositoriesToBuild" />.
        /// Once built the repositories will be made available for deployment. See the list of repositories available for deployment on <see cref="RepositoriesToDeploy" />.
        /// </remarks>
        public bool BuildRepositories()
        {
            bool result = false;

            if (_projectBuilder != null && _repositories != null && _repositories.Any(r => r.IsNeedingBuilding))
            {
                result = true;
                foreach (RepositoryEntity repository in _repositories.Where(r => r.IsNeedingBuilding))
                {
                    bool hasSolutionBeenSuccessfullyLoaded = _exceptionManager.Process(() => _projectBuilder.LoadSolutionFile(repository.SolutionFileToBuild), false, Resources.DefaultExceptionHandlingPolicyName);
                    if (hasSolutionBeenSuccessfullyLoaded)
                    {
                        bool hasSolutionBeenSuccessfullyBuilt = _exceptionManager.Process(() => _projectBuilder.BuildSolution(repository.SolutionConfigurationToBuild), false, Resources.DefaultExceptionHandlingPolicyName);
                        if (hasSolutionBeenSuccessfullyBuilt)
                        {
                            repository.IsNeedingBuilding   = false;
                            repository.IsNeedingDeployment = true;

                            // Saves current configuration to file so that changes to the IsNeedingBuilding and IsNeedingDeployment flags are not lost if the application exits.
                            SaveConfigurationToFile();
                        }
                        else
                        {
                            result = false;
                        }
                    }
                    else
                    {
                        result = false;
                    }
                }
            }

            return(result);
        }