Esempio n. 1
0
        /// <summary>
        /// Given existing template Program.cs Syntax Tree, Add configurations and generate new Syntax Tree.
        /// </summary>
        /// <param name="programTree">Syntax Tree for existing Program.cs Template</param>
        /// <returns>New root with updated Program.cs</returns>
        public SyntaxNode ReplaceProgramFile(SyntaxTree programTree)
        {
            Dictionary <string, int> transportPort = new Dictionary <string, int>();
            Dictionary <string, BindingConfiguration> bindingModeMap = new Dictionary <string, BindingConfiguration>();

            if (_projectType == ProjectType.WCFConfigBasedService)
            {
                string projectDir = _analyzerResult.ProjectResult.ProjectRootPath;
                bindingModeMap = GetBindingsTransportMap(projectDir);
                AddBinding(bindingModeMap, transportPort);
            }
            else
            {
                ProjectWorkspace project = _analyzerResult.ProjectResult;
                bindingModeMap = GetBindingsTransportMap(project);
                AddBinding(bindingModeMap, transportPort);
            }

            if (transportPort.IsNullOrEmpty())
            {
                return(programTree.GetRoot());
            }

            var containsTransportRelatedMode =
                bindingModeMap.Any(b =>
                                   b.Value.Mode.ToLower() == Constants.TransportMessageCredentialsMode.ToLower() ||
                                   b.Value.Mode.ToLower() == Constants.TransportMode.ToLower());

            var newRoot = ReplaceProgramNode(transportPort, programTree, containsTransportRelatedMode);

            return(newRoot);
        }
Esempio n. 2
0
        private ISyntax CreateAbnfSyntax()
        {
            var syntax = new Syntax();

            syntax.DefaultConverter.Add(CommonConverters.GuidConverter);
            syntax.DefaultConverter.Add(CommonConverters.Int32Converter);

            HostExtenderRef.Setup(syntax);
            HostExtenders.Setup(syntax);
            //LibidReference.Setup(syntax);
            ProjectId.Setup(syntax);
            ProjectDocModule.Setup(syntax);
            ProjectStdModule.Setup(syntax);
            ProjectClassModule.Setup(syntax);
            ProjectDesignerModule.Setup(syntax);
            ProjectPackage.Setup(syntax);
            ProjectProperties.Setup(syntax);
            ProjectReference.Setup(syntax);
            ProjectWindow.Setup(syntax);
            ProjectWindowState.Setup(syntax);
            ProjectWindowRecord.Setup(syntax);
            ProjectWorkspace.Setup(syntax);
            VBAPROJECTText.Setup(syntax);

            return(syntax);
        }
Esempio n. 3
0
        private ProjectWorkspace AnalyzeProject(ProjectBuildResult projectResult)
        {
            Logger.LogDebug("Analyzing the project: " + projectResult.ProjectPath);
            ProjectWorkspace workspace = new ProjectWorkspace(projectResult.ProjectPath)
            {
                SourceFiles      = new UstList <string>(projectResult.SourceFiles),
                BuildErrors      = projectResult.BuildErrors,
                BuildErrorsCount = projectResult.BuildErrors.Count
            };

            if (AnalyzerConfiguration.MetaDataSettings.ReferenceData)
            {
                workspace.ExternalReferences = projectResult.ExternalReferences;
            }
            workspace.TargetFramework  = projectResult.TargetFramework;
            workspace.TargetFrameworks = projectResult.TargetFrameworks;

            foreach (var fileBuildResult in projectResult.SourceFileBuildResults)
            {
                var fileAnalysis = AnalyzeFile(fileBuildResult, workspace.ProjectRootPath);
                workspace.SourceFileResults.Add(fileAnalysis);
            }

            return(workspace);
        }
Esempio n. 4
0
        private void toolStripMenuItemNewProject_Click(object sender, EventArgs e)
        {
            _logger.Trace("FormMain.toolStripMenuItemNewProject_Click()");

            try
            {
                SaveAndCloseProject(false);

                FormNewProject form = new FormNewProject();
                form.LoadLocalVariables();

                if (form.ShowDialog() == DialogResult.OK)
                {
                    _activeProject = form.Project;

                    _activeControl                  = new ProjectWorkspace();
                    _activeControl.Dock             = DockStyle.Fill;
                    _activeControl.Project          = _activeProject;
                    _activeControl.OnProjectChange += activeControl_OnProjectChange;
                    _activeControl.LoadLocalVariables();

                    UpdateWindowTitle();
                    UpdateMenuControls();

                    panelMain.Visible = true;
                    panelMain.Controls.Add(_activeControl);
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex, ex.Message);
                MessageBoxHelper.ProcessException(ex);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Determines if the project contains a file with the given extension.
        /// </summary>
        /// <param name="project">ProjectWorkspace to search</param>
        /// <param name="extension">Extension name to search for without '.'</param>
        /// <param name="searchSubdirectories">Whether or not to search recursively through directories</param>
        /// <returns>Whether or not a file with extesnion exists in the project directory</returns>
        /// <returns></returns>
        public static bool ContainsFileWithExtension(this ProjectWorkspace project, string extension,
                                                     bool searchSubdirectories = true)
        {
            var projectDirectory = project.ProjectRootPath;
            var searchOption     = searchSubdirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
            var searchPattern    = string.Join(".", "*", extension);

            return(Directory.EnumerateFiles(projectDirectory, searchPattern, searchOption).Any());
        }
Esempio n. 6
0
        protected override bool OnSaveCanExecute()
        {
            var result = ProjectWorkspace != null &&
                         !Project.HasErrors &&
                         ProjectWorkspace.All(pc => !pc.HasErrors) &&
                         HasChanges;

            return(result);
        }
Esempio n. 7
0
        /// <summary>
        /// Determines if a specified directory exists in the project directory and is non-empty
        /// </summary>
        /// <param name="project">ProjectWorkspace to search</param>
        /// <param name="directoryName">Name of directory to search for</param>
        /// <param name="searchSubdirectories">Whether or not to search recursively through directories</param>
        /// <returns>Whether or not the specified directory exists in the project directory and is not empty</returns>
        public static bool ContainsNonEmptyDirectory(this ProjectWorkspace project, string directoryName,
                                                     bool searchSubdirectories = true)
        {
            var projectDirectory = project.ProjectRootPath;
            var searchOption     = searchSubdirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
            var directories      = Directory.EnumerateDirectories(projectDirectory, directoryName, searchOption);

            return(directories.Any(d => Directory.EnumerateFiles(d, "*", searchOption).Any()));
        }
Esempio n. 8
0
 private void OnRemoveWorkspaceExecute()
 {
     SelectedProjectWorkspace.PropertyChanged -= ProjectWorkspaceWrapper_PropertyChanged;
     _projectRepository.RemoveProjectWorkspace(SelectedProjectWorkspace.Model);
     ProjectWorkspace.Remove(SelectedProjectWorkspace);
     SelectedProjectWorkspace = null;
     HasChanges = _projectRepository.HasChanges();
     ((DelegateCommand)SaveCommand).RaiseCanExecuteChanged();
 }
Esempio n. 9
0
        private void InitializeProjetWrappers(int projectId)
        {
            var projectWorkspace = _projectRepository.GetProjectWorkspacesForProject(projectId);

            foreach (var wrapper in ProjectWorkspace)
            {
                wrapper.PropertyChanged -= ProjectWorkspaceWrapper_PropertyChanged;
            }
            ProjectWorkspace.Clear();
            foreach (var item in projectWorkspace)
            {
                var wrapper = new ProjectWorkspaceWrapper(item);
                ProjectWorkspace.Add(wrapper);
                wrapper.PropertyChanged += ProjectWorkspaceWrapper_PropertyChanged;
            }
        }
Esempio n. 10
0
        public void Setup()
        {
            SolutionPath = "temp/solutionPath";
            ProjectPath  = "temp/solutionPath";

            var projectResult = new ProjectWorkspace(ProjectPath)
            {
                ProjectGuid = "1234-5678"
            };
            var analyzerResult = new AnalyzerResult
            {
                ProjectResult = projectResult
            };
            var analyzerResults = new List <AnalyzerResult>
            {
                analyzerResult
            };

            Context = new MetricsContext(SolutionPath, analyzerResults);
        }
Esempio n. 11
0
        public override object ReadJson(JsonReader reader,
                                        Type objectType, object existingValue, JsonSerializer serializer)
        {
            JObject jObject = JObject.Load(reader);

            var type = jObject["type"];

            if (type != null)
            {
                string  ustType = type.ToString();
                UstNode item    = ModelFactory.GetObject(ustType);
                serializer.Populate(jObject.CreateReader(), item);
                return(item);
            }
            else
            {
                ProjectWorkspace item = new ProjectWorkspace("");
                serializer.Populate(jObject.CreateReader(), item);
                return(item);
            }
        }
Esempio n. 12
0
        private void SavePathInProject(string selectedPath)
        {
            var existingWorkspacesForProject
                = _projectRepository.GetProjectWorkspacesForProject(Project.Id);

            if (existingWorkspacesForProject.Where(p => p.WorkspacePath == selectedPath).Count() == 0)
            {
                var newWorkspace = new ProjectWorkspaceWrapper(new ProjectWorkspace());
                newWorkspace.WorkspacePath = selectedPath;

                Project.Model.ProjectWorkspaces.Add(newWorkspace.Model);
                //TODO - Integrate with whole model validations
                OnSaveExecute();

                ProjectWorkspace.Add(newWorkspace);
            }
            else
            {
                //TODO: Implement info for user, that path already exists
            }
        }
Esempio n. 13
0
        protected FilesFolderCommand(ProjectWorkspace project, IMessageBus messaging, ToolboxSocket socket)
        {
            Project   = project;
            Messaging = messaging;
            Socket    = socket;

            messaging.Listen <ProjectFileSelected>(payload =>
            {
                SelectedFile   = payload.File.FullPath;
                SelectedFolder = string.Empty;

                SetProjectData();
            });

            messaging.Listen <ProjectFolderSelected>(payload =>
            {
                SelectedFolder = payload.Folder.FullPath;
                SelectedFile   = string.Empty;

                SetProjectData();
            });
        }
Esempio n. 14
0
        private void OpenProject(string projectLocation)
        {
            _logger.Trace("FormMain.OpenProject()");

            _activeProject = ProjectsController.OpenProjectFromLocation(projectLocation, Resources.EncriptionKey);

            if (!_activeProject.IsValid)
            {
                return;
            }

            _activeControl                  = new ProjectWorkspace();
            _activeControl.Dock             = DockStyle.Fill;
            _activeControl.Project          = _activeProject;
            _activeControl.OnProjectChange += activeControl_OnProjectChange;
            _activeControl.LoadLocalVariables();

            UpdateWindowTitle();
            UpdateMenuControls();

            panelMain.Visible = true;
            panelMain.Controls.Add(_activeControl);
        }
Esempio n. 15
0
        private ProjectWorkspace AnalyzeProject(ProjectBuildResult projectResult)
        {
            Logger.LogDebug("Analyzing the project: " + projectResult.ProjectPath);
            ProjectWorkspace workspace = new ProjectWorkspace(projectResult.ProjectPath)
            {
                SourceFiles      = new UstList <string>(projectResult.SourceFiles),
                BuildErrors      = projectResult.BuildErrors,
                BuildErrorsCount = projectResult.BuildErrors.Count
            };

            if (AnalyzerConfiguration.MetaDataSettings.ReferenceData)
            {
                workspace.ExternalReferences = projectResult.ExternalReferences;
            }
            workspace.TargetFramework  = projectResult.TargetFramework;
            workspace.TargetFrameworks = projectResult.TargetFrameworks;

            foreach (var fileBuildResult in projectResult.SourceFileBuildResults)
            {
                CodeContext codeContext = new CodeContext(fileBuildResult.SemanticModel,
                                                          fileBuildResult.SyntaxTree,
                                                          workspace.ProjectRootPath,
                                                          fileBuildResult.SourceFilePath,
                                                          AnalyzerConfiguration,
                                                          Logger);

                Logger.LogDebug("Analyzing: " + fileBuildResult.SourceFileFullPath);

                using (CSharpRoslynProcessor processor = new CSharpRoslynProcessor(codeContext))
                {
                    var result = processor.Visit(codeContext.SyntaxTree.GetRoot());
                    workspace.SourceFileResults.Add((RootUstNode)result);
                }
            }

            return(workspace);
        }
Esempio n. 16
0
 public OpenXamlCommand(ProjectWorkspace project, IMessageBus messaging, ToolboxSocket socket)
     : base(project, messaging, socket)
 {
     MenuText = "Open XAML";
     ToolTip  = "Open for editing.";
 }
Esempio n. 17
0
 public OpenVisualStudioCommand(ProjectWorkspace project, IMessageBus messaging, ToolboxSocket socket)
     : base(project, messaging, socket)
 {
     MenuText = "Open in Visual Studio";
 }
Esempio n. 18
0
 /// <summary>
 /// Determines if a ProjectWorkspace has a specified Nuget Dependency
 /// </summary>
 /// <param name="project">ProjectWorkspace to search</param>
 /// <param name="nugetReferenceIdentifier">Nuget reference to search for</param>
 /// <returns>Whether or not the nuget reference exists in the project</returns>
 public static bool ContainsNugetDependency(this ProjectWorkspace project, string nugetReferenceIdentifier)
 => project.ExternalReferences?.NugetReferences
 .Any(r => r.Identity == nugetReferenceIdentifier) == true;
Esempio n. 19
0
 /// <summary>
 /// Determines if a ProjectWorkspace has a specified Dependency
 /// </summary>
 /// <param name="project">ProjectWorkspace to search</param>
 /// <param name="referenceIdentifier">Reference to search for</param>
 /// <returns>Whether or not the reference exists in the project</returns>
 public static bool ContainsDependency(this ProjectWorkspace project, string referenceIdentifier)
 => project.ExternalReferences?.NugetReferences
 .Union(project.ExternalReferences?.NugetDependencies)
 .Union(project.ExternalReferences?.SdkReferences)
 .Any(r => r.Identity == referenceIdentifier) == true;
Esempio n. 20
0
 /// <summary>
 /// Get all object creation expressions in project with the given Semantic Class Type
 /// </summary>
 /// <param name="project">ProjectWorkspace to search</param>
 /// <param name="semanticClassType">Semantic Class Type to search for</param>
 /// <returns></returns>
 public static IEnumerable <ObjectCreationExpression> GetObjectCreationExpressionBySemanticClassType(this ProjectWorkspace project, string semanticClassType)
 => project.SourceFileResults.SelectMany(r => r.AllObjectCreationExpressions().Where(o => o.SemanticClassType == semanticClassType));
Esempio n. 21
0
        /// <summary>
        /// Handles the process of building the core components
        /// </summary>
        private void BuildApplicationCore(bool fullBuild)
        {
            ServiceCollection services = ApplicationContext.Current.Services;

            var cm = services.Get<Sage.Platform.Configuration.ConfigurationManager>(true);
            cm.RegisterConfigurationType(typeof(BuildSettings));

            var settings = cm.GetConfiguration<BuildSettings>();
            settings.SolutionFolder = Manifest.OutputPath;
            settings.AcceptChanges();

            cm.WriteConfiguration(settings);

            var modelTypes = new ModelTypeCollection();
            RegisterRequiredModels(modelTypes);

            string vfsPath = string.Empty;
            if (string.IsNullOrEmpty(Manifest.VFSPath))
                vfsPath = ProjectWorkspace.VFS_MODEL_PATH;
            else
                vfsPath = Manifest.VFSPath;

            var workspace = new ProjectWorkspace(vfsPath)
            {
                Name = "TEMP_VFS"
            };

            using (IProject project = new Project(workspace, modelTypes))
            {

                RegisterNeededServices(services, project);

                var service = (Platforms)ExtensionManager.Default.GetService(typeof(Platforms));

                if (fullBuild)
                {
                    log.Info(Resources.log_building_core);

                    try
                    {

                        VFSQuery.UpgradeToBatchMode();
                        var files = new List<string>();

                        // Build Interfaces
                        string[] interfaceFiles = BuildPlatform(project, service, PlatformGuids.CommonGuid);
                        files.AddRange(interfaceFiles);
                        OnBuildComplete(files.ToArray());
                        files.AddRange(BuildPlatform(project, service, PlatformGuids.WebGuid));

                        GenerateCodeSnippetLibraries(project);
                        GenerateRulesConfiguration(project);

                    }
                    catch (Exception ex)
                    {

                    }
                    finally
                    {
                        VFSQuery.DowngradeFromBatchMode();
                    }

                }
            }
        }
Esempio n. 22
0
        public static Dictionary <string, BindingConfiguration> GetBindingsTransportMap(ProjectWorkspace project)
        {
            Dictionary <string, BindingConfiguration> bindingsTransportMap = new Dictionary <string, BindingConfiguration>();

            WCFBindingAndTransportUtil.CodeBasedCheck(project, bindingsTransportMap);

            return(bindingsTransportMap);
        }
Esempio n. 23
0
        /// <summary>
        /// Given existing Startup.cs template file, generate new Startup.cs based on configuration.
        /// </summary>
        /// <param name="startupFilePath">Path to existing Startup.cs template</param>
        /// <returns>New Startup.cs contents</returns>
        public string ReplaceStartupFile(string startupFilePath)
        {
            var startupFileContents = File.ReadAllText(startupFilePath);

            if (_projectType == ProjectType.WCFConfigBasedService)
            {
                string configPath = Path.Combine(_projectPath, Constants.PortedConfigFileName);

                if (HasBehavioursTag())
                {
                    startupFileContents = HandleBehaviorsTag(startupFilePath);
                }

                return(startupFileContents.Replace(Constants.XMLPathPlaceholder, "@\"" + configPath + "\""));
            }
            else
            {
                string addService             = Constants.AddServiceFormat;
                string endpointConfigTemplate = Constants.AddServiceEndpointFormat;
                string endpointConfigs        = "";

                ProjectWorkspace project = _analyzerResult.ProjectResult;

                Dictionary <string, BindingConfiguration> bindingTransportMap = GetBindingsTransportMap(project);

                Tuple <string, string> serviceInterfaceAndClass = WCFBindingAndTransportUtil.GetServiceInterfaceAndClass(project);

                var serviceInterfaceName = serviceInterfaceAndClass.Item1 ?? Constants.DefaultServiceInterface;
                var serviceClassName     = serviceInterfaceAndClass.Item2 ?? Constants.DefaultServiceClass;

                endpointConfigs += String.Format(addService, serviceClassName);

                foreach (KeyValuePair <string, BindingConfiguration> keyValuePair in bindingTransportMap)
                {
                    var binding         = keyValuePair.Key;
                    var mode            = keyValuePair.Value.Mode;
                    var endpointAddress = keyValuePair.Value.EndpointAddress ?? String.Join("", "\"", "/", binding.ToLower(), "\"");

                    if (mode.ToLower() == Constants.TransportMode.ToLower())
                    {
                        mode = Constants.TransportMode;
                    }
                    else if (mode.ToLower() == Constants.TransportMessageCredentialsMode.ToLower())
                    {
                        mode = Constants.TransportMessageCredentialsMode;
                    }

                    if (binding == Constants.HttpProtocol)
                    {
                        endpointConfigs += String.Format(endpointConfigTemplate, serviceClassName, serviceInterfaceName,
                                                         mode == Constants.NoneMode ? "new BasicHttpBinding()" : "new BasicHttpBinding(BasicHttpSecurityMode." + mode + ")", endpointAddress);
                    }
                    else if (binding == Constants.NettcpProtocol)
                    {
                        endpointConfigs += String.Format(endpointConfigTemplate, serviceClassName, serviceInterfaceName,
                                                         mode == Constants.NoneMode ? "new NetTcpBinding()" : "new NetTcpBinding(SecurityMode." + mode + ")", endpointAddress);
                    }
                    else if (binding == Constants.WSHttpProtocol)
                    {
                        endpointConfigs += String.Format(endpointConfigTemplate, serviceClassName, serviceInterfaceName,
                                                         mode == Constants.NoneMode ? "new WSHttpBinding()" : "new WSHttpBinding(SecurityMode." + mode + ")", endpointAddress);
                    }
                    else if (binding == Constants.HttpsProtocol)
                    {
                        endpointConfigs += String.Format(endpointConfigTemplate, serviceClassName, serviceInterfaceName, "new BasicHttpBinding(BasicHttpSecurityMode.Transport)", endpointAddress);
                    }
                    else if (binding == Constants.NethttpProtocol)
                    {
                        endpointConfigs += String.Format(endpointConfigTemplate, serviceClassName, serviceInterfaceName,
                                                         mode == Constants.NoneMode ? "new NetHttpBinding()" : "new NetHttpBinding(BasicHttpSecurityMode." + mode + ")", endpointAddress);
                    }
                }

                return(startupFileContents.Replace(Constants.EndpointPlaceholder, endpointConfigs));
            }
        }
Esempio n. 24
0
 /// <summary>
 /// Gets all Invocation Expressions with the given method name.
 /// </summary>
 /// <param name="project">ProjectWorkspace to search</param>
 /// <param name="methodName">Method name to search for</param>
 /// <returns>Collection of invocation expressions with given method name</returns>
 public static IEnumerable <InvocationExpression> GetInvocationExpressionsByMethodName(this ProjectWorkspace project, string methodName)
 => project.SourceFileResults.SelectMany(r => r.AllInvocationExpressions().Where(i => i.MethodName == methodName));
Esempio n. 25
0
 /// <summary>
 /// Determines if a ProjectWorkspace declares a class with a specified base type
 /// </summary>
 /// <param name="project">ProjectWorkspace to search</param>
 /// <param name="typeOriginalDefinition">Original Definition of the base type being searched for</param>
 /// <returns>Whether or not a class with the specified base type is declared in the project</returns>
 public static bool DeclaresClassWithBaseType(this ProjectWorkspace project, string typeOriginalDefinition)
 => project.SourceFileResults
 .SelectMany(n => n.AllClasses())
 .Any(c => c.BaseTypeOriginalDefinition == typeOriginalDefinition);
Esempio n. 26
0
 /// <summary>
 /// Gets all class declaration nodes in a ProjectWorkspace
 /// </summary>
 /// <param name="project">ProjectWorkspace to search</param>
 /// <returns>Collection of class declaration nodes in the project with the specified base type</returns>
 public static IEnumerable <ClassDeclaration> GetAllClassDeclarations(this ProjectWorkspace project)
 => project.SourceFileResults.SelectMany(r => r.AllClasses());
Esempio n. 27
0
 /// <summary>
 /// Gets all class declaration nodes in a ProjectWorkspace derived from a specified base type
 /// </summary>
 /// <param name="project">ProjectWorkspace to search</param>
 /// <param name="baseTypeOriginalDefinition">ProjectWorkspace to search</param>
 /// <returns>Collection of class declaration nodes in the project with the specified base type</returns>
 public static IEnumerable <ClassDeclaration> GetClassDeclarationsByBaseType(this ProjectWorkspace project,
                                                                             string baseTypeOriginalDefinition)
 => project.GetAllClassDeclarations().Where(c => c.HasBaseType(baseTypeOriginalDefinition));
Esempio n. 28
0
 public void Dispose()
 {
     ProjectResult = null;
     ProjectBuildResult?.Dispose();
     ProjectBuildResult = null;
 }
Esempio n. 29
0
 public OpenNotepadCommand(ProjectWorkspace project, IMessageBus messaging, ToolboxSocket socket)
     : base(project, messaging, socket)
 {
     MenuText = "Open in Notepad";
 }
Esempio n. 30
0
 public OpenFolderCommand(ProjectWorkspace project, IMessageBus messaging, ToolboxSocket socket)
     : base(project, messaging, socket)
 {
     MenuText = "Open in File Explorer";
 }
Esempio n. 31
0
 public WatchXamlCommand(ProjectWorkspace project, IMessageBus messaging, ToolboxSocket socket)
     : base(project, messaging, socket)
 {
     MenuText = "Watch for Changes";
     ToolTip  = "Continually send external changes made to the XAML file to the designer.";
 }
        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);
        }