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))); }
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()); }
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()); }
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)); } }
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})")); }