diff --git a/src/dotnet/commands/dotnet-migrate/LocalizableStrings.cs b/src/dotnet/commands/dotnet-migrate/LocalizableStrings.cs index f443a269c..ca83f4387 100644 --- a/src/dotnet/commands/dotnet-migrate/LocalizableStrings.cs +++ b/src/dotnet/commands/dotnet-migrate/LocalizableStrings.cs @@ -32,5 +32,33 @@ Defaults to current directory if nothing is specified."; public const string MigrationFailedError = "Migration failed."; public const string MigrationAdditionalHelp = "Your project has been migrated to the .csproj format and can be used with this build of the .NET Core Tools. Please visit https://aka.ms/coremigration to report issues or ask for help."; + + public const string MigrationReportSummary = "Summary"; + + public const string MigrationReportTotalProjects = "Total Projects: {0}"; + + public const string MigrationReportSucceededProjects = "Succeeded Projects: {0}"; + + public const string MigrationReportFailedProjects = "Failed Projects: {0}"; + + public const string ProjectMigrationSucceeded = "Project {0} migration succeeded ({1})."; + + public const string ProjectMigrationFailed = "Project {0} migration failed ({1})."; + + public const string MigrationFailedToFindProjectInGlobalJson = "Unable to find any projects in global.json."; + + public const string MigrationUnableToFindProjects = "Unable to find any projects in {0}."; + + public const string MigrationProjectJsonNotFound = "No project.json file found in '{0}'."; + + public const string MigrationInvalidProjectArgument = "Invalid project argument - '{0}' is not a project.json, global.json, or solution.sln file and a directory named '{0}' doesn't exist."; + + public const string MigratonUnableToFindProjectJson = "Unable to find project.json file at {0}."; + + public const string MigrationUnableToFindGlobalJson = "Unable to find global settings file at {0}."; + + public const string MigrationUnableToFindSolutionFile = "Unable to find the solution file at {0}."; + + public const string MigrateFilesBackupLocation = "Files backed up to {0}"; } } \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-migrate/MigrateCommand.cs b/src/dotnet/commands/dotnet-migrate/MigrateCommand.cs index bc7e6b444..34c8bbc53 100644 --- a/src/dotnet/commands/dotnet-migrate/MigrateCommand.cs +++ b/src/dotnet/commands/dotnet-migrate/MigrateCommand.cs @@ -214,7 +214,9 @@ namespace Microsoft.DotNet.Tools.Migrate backupPlan.PerformBackup(); - Reporter.Output.WriteLine($"Files backed up to {backupPlan.RootBackupDirectory.FullName}"); + Reporter.Output.WriteLine(string.Format( + LocalizableStrings.MigrateFilesBackupLocation, + backupPlan.RootBackupDirectory.FullName)); } private void WriteReport(MigrationReport migrationReport) @@ -285,10 +287,15 @@ namespace Microsoft.DotNet.Tools.Migrate { StringBuilder sb = new StringBuilder(); - sb.AppendLine("Summary"); - sb.AppendLine($"Total Projects: {migrationReport.MigratedProjectsCount}"); - sb.AppendLine($"Succeeded Projects: {migrationReport.SucceededProjectsCount}"); - sb.AppendLine($"Failed Projects: {migrationReport.FailedProjectsCount}"); + sb.AppendLine(LocalizableStrings.MigrationReportSummary); + sb.AppendLine( + string.Format(LocalizableStrings.MigrationReportTotalProjects, migrationReport.MigratedProjectsCount)); + sb.AppendLine(string.Format( + LocalizableStrings.MigrationReportSucceededProjects, + migrationReport.SucceededProjectsCount)); + sb.AppendLine(string.Format( + LocalizableStrings.MigrationReportFailedProjects, + migrationReport.FailedProjectsCount)); return sb.ToString(); } @@ -296,7 +303,10 @@ namespace Microsoft.DotNet.Tools.Migrate private string GetProjectReportSuccessContent(ProjectMigrationReport projectMigrationReport, bool colored) { Func GreenIfColored = (str) => colored ? str.Green() : str; - return GreenIfColored($"Project {projectMigrationReport.ProjectName} migration succeeded ({projectMigrationReport.ProjectDirectory})"); + return GreenIfColored(string.Format( + LocalizableStrings.ProjectMigrationSucceeded, + projectMigrationReport.ProjectName, + projectMigrationReport.ProjectDirectory)); } private string GetProjectReportErrorContent(ProjectMigrationReport projectMigrationReport, bool colored) @@ -306,7 +316,10 @@ namespace Microsoft.DotNet.Tools.Migrate if (projectMigrationReport.Errors.Any()) { - sb.AppendLine(RedIfColored($"Project {projectMigrationReport.ProjectName} migration failed ({projectMigrationReport.ProjectDirectory})")); + sb.AppendLine(RedIfColored(string.Format( + LocalizableStrings.ProjectMigrationFailed, + projectMigrationReport.ProjectName, + projectMigrationReport.ProjectDirectory))); foreach (var error in projectMigrationReport.Errors.Select(e => e.GetFormattedErrorMessage())) { @@ -336,7 +349,7 @@ namespace Microsoft.DotNet.Tools.Migrate if (!projects.Any()) { - throw new GracefulException("Unable to find any projects in global.json"); + throw new GracefulException(LocalizableStrings.MigrationFailedToFindProjectInGlobalJson); } } else if (File.Exists(projectArg) && @@ -346,7 +359,8 @@ namespace Microsoft.DotNet.Tools.Migrate if (!projects.Any()) { - throw new GracefulException($"Unable to find any projects in {projectArg}"); + throw new GracefulException( + string.Format(LocalizableStrings.MigrationUnableToFindProjects, projectArg)); } } else if (Directory.Exists(projectArg)) @@ -355,12 +369,14 @@ namespace Microsoft.DotNet.Tools.Migrate if (!projects.Any()) { - throw new GracefulException($"No project.json file found in '{projectArg}'"); + throw new GracefulException( + string.Format(LocalizableStrings.MigrationProjectJsonNotFound, projectArg)); } } else { - throw new GracefulException($"Invalid project argument - '{projectArg}' is not a project.json, global.json, or solution.sln file and a directory named '{projectArg}' doesn't exist."); + throw new GracefulException( + string.Format(LocalizableStrings.MigrationInvalidProjectArgument, projectArg)); } foreach (var project in projects) @@ -386,7 +402,7 @@ namespace Microsoft.DotNet.Tools.Migrate return projectJson; } - throw new GracefulException($"Unable to find project file at {projectJson}"); + throw new GracefulException(string.Format(LocalizableStrings.MigratonUnableToFindProjectJson, projectJson)); } private IEnumerable GetProjectsFromGlobalJson(string globalJson) @@ -418,7 +434,8 @@ namespace Microsoft.DotNet.Tools.Migrate { if (!File.Exists(globalJson)) { - throw new GracefulException($"Unable to find global settings file at {globalJson}"); + throw new GracefulException( + string.Format(LocalizableStrings.MigrationUnableToFindGlobalJson, globalJson)); } var globalJsonDirectory = Path.GetDirectoryName(globalJson); @@ -429,7 +446,8 @@ namespace Microsoft.DotNet.Tools.Migrate { if (!File.Exists(slnPath)) { - throw new GracefulException($"Unable to find the solution file at {slnPath}"); + throw new GracefulException( + string.Format(LocalizableStrings.MigrationUnableToFindSolutionFile, slnPath)); } _slnFile = SlnFile.Read(slnPath); diff --git a/src/dotnet/commands/dotnet-test/LocalizableStrings.cs b/src/dotnet/commands/dotnet-test/LocalizableStrings.cs index af567dceb..16159aa0f 100644 --- a/src/dotnet/commands/dotnet-test/LocalizableStrings.cs +++ b/src/dotnet/commands/dotnet-test/LocalizableStrings.cs @@ -55,7 +55,8 @@ public const string RunSettingsArgsHelpText = @"Any extra commandline runsettings arguments that should be passed to vstest. See 'dotnet vstest --help' for available options. Example: -- RunConfiguration.ResultsDirectory=""C:\users\user\desktop\Results Directory"" MSTest.DeploymentEnabled=false"; - public const string CmdResultsDirectoryDescription = @"Test results directory will be created in specified path if not exists. + + public const string CmdResultsDirectoryDescription = @"The test results directory will be created in the specified path if it does not exist. Example: --results-directory "; } }