Beispiel #1
0
        private string GetProjectReportSuccessContent(ProjectMigrationReport projectMigrationReport, bool colored)
        {
            Func <string, string> GreenIfColored = (str) => colored?str.Green() : str;

            return(GreenIfColored(string.Format(
                                      LocalizableStrings.ProjectMigrationSucceeded,
                                      projectMigrationReport.ProjectName,
                                      projectMigrationReport.ProjectDirectory)));
        }
Beispiel #2
0
        private string GetProjectReportWarningContent(ProjectMigrationReport projectMigrationReport, bool colored)
        {
            StringBuilder         sb = new StringBuilder();
            Func <string, string> YellowIfColored = (str) => colored?str.Yellow() : str;

            foreach (var warning in projectMigrationReport.Warnings)
            {
                sb.AppendLine(YellowIfColored(warning));
            }

            return(sb.ToString());
        }
Beispiel #3
0
        private string GetProjectReportErrorContent(ProjectMigrationReport projectMigrationReport, bool colored)
        {
            StringBuilder         sb           = new StringBuilder();
            Func <string, string> RedIfColored = (str) => colored?str.Red() : str;

            if (projectMigrationReport.Errors.Any())
            {
                sb.AppendLine(RedIfColored($"Project {projectMigrationReport.ProjectName} migration failed ({projectMigrationReport.ProjectDirectory})"));

                foreach (var error in projectMigrationReport.Errors.Select(e => e.GetFormattedErrorMessage()))
                {
                    sb.AppendLine(RedIfColored(error));
                }
            }

            return(sb.ToString());
        }
Beispiel #4
0
        private void MigrateProject(ProjectMigrationReport report)
        {
            var projectDirectory = PathUtility.EnsureTrailingSlash(report.ProjectDirectory);

            var relativeDirectory = PathUtility.GetRelativePath(PathUtility.EnsureTrailingSlash(_workspaceDirectory.FullName), projectDirectory);

            var targetDirectory = String.IsNullOrEmpty(relativeDirectory)
                ? _backupDirectory.FullName
                :  Path.Combine(_backupDirectory.FullName, relativeDirectory);

            PathUtility.EnsureDirectory(PathUtility.EnsureTrailingSlash(targetDirectory));

            var movableFiles = new DirectoryInfo(projectDirectory)
                               .EnumerateFiles()
                               .Where(f => f.Name == Project.FileName || f.Extension == ".xproj");

            foreach (var movableFile in movableFiles)
            {
                movableFile.MoveTo(Path.Combine(targetDirectory, movableFile.Name));
            }
        }
Beispiel #5
0
        private string GetProjectReportSuccessContent(ProjectMigrationReport projectMigrationReport, bool colored)
        {
            Func <string, string> GreenIfColored = (str) => colored?str.Green() : str;

            return(GreenIfColored($"Project {projectMigrationReport.ProjectName} migration succeeded ({projectMigrationReport.ProjectDirectory})"));
        }