public ProjectInstallInfo IdentifyProjectVersion(string projectPath)
        {
            _log.Info(string.Format("Analyzing files in {0} to determine versioning information...", projectPath));
            Dictionary<string, List<FileReleaseInfo>> projMatchInfo = FindAllMatchingReleasesInProject(projectPath);
            if (projMatchInfo == null || !projMatchInfo.Any())
                throw new InvalidProjectException("Project Version could not be determined.  No files were found.", projectPath);

            IDriveInfo projectDrive = FileSystem.FileSystem.GetDriveFromPath(projectPath);
            RegisteredProjectInfo projectInfo = DetermineProjectVersionFromMatches(projMatchInfo.Values);
            _log.Info("Project Version: " + projectInfo.Name);

            IEnumerable<BundleInfo> bundlesByMatches = FindInstalledBundlesByMatches(projMatchInfo.Values, projectInfo.MainVersion);
            IEnumerable<BundleInfo> bundlesFromManifests = GetBundleInfosFromProject(projectDrive);

            var installInfo = new ProjectInstallInfo(projectInfo,
                                          GetBundlesApplied(bundlesByMatches, bundlesFromManifests),
                                          GetPossibleBundlesApplied(bundlesByMatches, bundlesFromManifests));

            if (installInfo.BundlesApplied.Any())
            {
                _log.Info("Bundles installed:");
                installInfo.BundlesApplied.ForEach(bundle =>
                    _log.Info(string.Format("\t{0} {1}", bundle.Name, bundle.Version)));
                _log.Info("");
            }
            else
            {
                _log.Info("No SalesLogix bundles have been installed.");
            }

            if (installInfo.PossibleBundlesApplied.Any())
            {
                _log.Warn("The following bundles may have been applied, but the associated files were not found:");
                installInfo.PossibleBundlesApplied.ForEach(bundle =>
                    _log.Warn(string.Format("{0} {1}", bundle.Name, bundle.Version)));
                _log.Info("");
            }

            return installInfo;
        }
        public bool BuildBaseProject(ProjectInstallInfo installedProjectInfo, IDirectoryInfo projectBackupDir, string baseProjectPath)
        {
            if (!projectBackupDir.Exists)
                throw new ArgumentException("Path does not exist.", "projectBackupPath");

            if (string.IsNullOrEmpty(installedProjectInfo.ProjectVersionInfo.BackupFileName))
                throw new ArgumentException("BackupFileName is not set.", "projectInfo");

            IFileInfo backupFile = projectBackupDir.GetFiles(installedProjectInfo.ProjectVersionInfo.BackupFileName).FirstOrDefault();
            if (backupFile == null)
            {
                throw new ApplicationException(string.Format("Project backup file {0} does not exist.",
                    Path.Combine(projectBackupDir.FullName, installedProjectInfo.ProjectVersionInfo.BackupFileName)));
            }

            IDirectoryInfo baseDir = FileSystem.FileSystem.GetDirectoryInfo(baseProjectPath);
            if (!baseDir.Exists)
                baseDir.Create();

            var bundlesToInstall = installedProjectInfo.BundlesApplied
                .OrderBy(b => b.Version.Major)
                .ThenBy(b => b.Version.Minor)
                .ThenBy(b => b.Version.Build)
                .ThenBy(b => b.Version.Revision);

            //ensure we can find all the bundle files
            foreach (BundleInfo bundleInfo in bundlesToInstall)
            {
                if (!BundleExistsInRepository(projectBackupDir, bundleInfo.FileName))
                {
                    _log.Error(string.Format("The bundle file \"{0}\" could not be found.", bundleInfo.FileName));
                    Environment.Exit(-1);
                }
            }

            var backup = new ProjectBackup(backupFile.FullName);
            var workspace = new ProjectWorkspace(baseProjectPath);
            workspace.RestoreProjectFromBackup(backup);
            IProject project = new Project(workspace);
            var pcs = new SimpleProjectContextService(project);
            ApplicationContext.Current.Services.Add(typeof(IProjectContextService), pcs);

            var installResults = bundlesToInstall.Select(bundleInfo =>
                InstallBundle(projectBackupDir.FullName, bundleInfo.FileName, project));
            return installResults.All(result => result);
        }