Localizing Microsoft.DotNet.Cli.Utils.

This commit is contained in:
Livar Cunha 2016-12-16 22:41:06 -08:00
parent fddabd4a51
commit 1be6365e56
19 changed files with 262 additions and 55 deletions

View file

@ -118,7 +118,10 @@ namespace Microsoft.DotNet.Cli.Utils
public CommandResult Execute()
{
Reporter.Verbose.WriteLine($"Running {_process.StartInfo.FileName} {_process.StartInfo.Arguments}");
Reporter.Verbose.WriteLine(string.Format(
LocalizableStrings.RunningFileNameArguments,
_process.StartInfo.FileName,
_process.StartInfo.Arguments));
ThrowIfRunning();
@ -135,7 +138,9 @@ namespace Microsoft.DotNet.Cli.Utils
{
_process.Start();
Reporter.Verbose.WriteLine($"Process ID: {_process.Id}");
Reporter.Verbose.WriteLine(string.Format(
LocalizableStrings.ProcessId,
_process.Id));
var taskOut = _stdOut?.BeginRead(_process.StandardOutput);
var taskErr = _stdErr?.BeginRead(_process.StandardError);
@ -148,7 +153,11 @@ namespace Microsoft.DotNet.Cli.Utils
var exitCode = _process.ExitCode;
#if DEBUG
var message = $"< {FormatProcessInfo(_process.StartInfo)} exited with {exitCode} in {sw.ElapsedMilliseconds} ms.";
var message = string.Format(
LocalizableStrings.ProcessExitedWithCode,
FormatProcessInfo(_process.StartInfo),
exitCode,
sw.ElapsedMilliseconds);
if (exitCode == 0)
{
Reporter.Verbose.WriteLine(message.Green());
@ -288,7 +297,9 @@ namespace Microsoft.DotNet.Cli.Utils
{
if (_running)
{
throw new InvalidOperationException($"Unable to invoke {memberName} after the command has been run");
throw new InvalidOperationException(string.Format(
LocalizableStrings.UnableToInvokeMemberNameAfterCommand,
memberName));
}
}
}

View file

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.DotNet.Cli.Utils;
namespace Microsoft.DotNet.Cli.Utils.CommandParsing
{
@ -54,7 +55,7 @@ namespace Microsoft.DotNet.Cli.Utils.CommandParsing
var result = grammar.Parse(cursor);
if (!result.Remainder.IsEnd)
{
throw new ArgumentException($"Malformed command text '{text}'", nameof(text));
throw new ArgumentException(string.Format(LocalizableStrings.MalformedText, nameof(text)));
}
return result.Value.ToArray();
}

View file

@ -59,7 +59,8 @@ namespace Microsoft.DotNet.Cli.Utils
if (!Directory.Exists(buildOutputPath))
{
Reporter.Verbose.WriteLine($"outputpathresolver: {buildOutputPath} does not exist");
Reporter.Verbose.WriteLine(
string.Format(LocalizableStrings.BuildOutputPathDoesNotExist, buildOutputPath));
return null;
}

View file

@ -10,6 +10,8 @@ namespace Microsoft.DotNet.Cli.Utils
{
public class PackagedCommandSpecFactory : IPackagedCommandSpecFactory
{
private const string PackagedCommandSpecFactoryName = "packagedcommandspecfactory";
private Action<string, IList<string>> _addAdditionalArguments;
internal PackagedCommandSpecFactory(Action<string, IList<string>> addAdditionalArguments = null)
@ -27,14 +29,21 @@ namespace Microsoft.DotNet.Cli.Utils
string depsFilePath,
string runtimeConfigPath)
{
Reporter.Verbose.WriteLine($"packagedcommandspecfactory: attempting to find command {commandName} in {toolLibrary.Name}");
Reporter.Verbose.WriteLine(string.Format(
LocalizableStrings.AttemptingToFindCommand,
PackagedCommandSpecFactoryName,
commandName,
toolLibrary.Name));
var toolAssembly = toolLibrary?.RuntimeAssemblies
.FirstOrDefault(r => Path.GetFileNameWithoutExtension(r.Path) == commandName);
if (toolAssembly == null)
{
Reporter.Verbose.WriteLine($"packagedcommandspecfactory: failed to find toolAssembly for {commandName}");
Reporter.Verbose.WriteLine(string.Format(
LocalizableStrings.FailedToFindToolAssembly,
PackagedCommandSpecFactoryName,
commandName));
return null;
}
@ -43,7 +52,10 @@ namespace Microsoft.DotNet.Cli.Utils
if (!File.Exists(commandPath))
{
Reporter.Verbose.WriteLine($"packagedcommandspecfactory: failed to find commandPath {commandPath}");
Reporter.Verbose.WriteLine(string.Format(
LocalizableStrings.FailedToFindCommandPath,
PackagedCommandSpecFactoryName,
commandPath));
return null;
}
@ -57,12 +69,17 @@ namespace Microsoft.DotNet.Cli.Utils
runtimeConfigPath);
}
private string GetCommandFilePath(string nugetPackagesRoot, LockFileTargetLibrary toolLibrary, LockFileItem runtimeAssembly)
private string GetCommandFilePath(
string nugetPackagesRoot,
LockFileTargetLibrary toolLibrary,
LockFileItem runtimeAssembly)
{
var packageDirectory = new VersionFolderPathResolver(nugetPackagesRoot)
.GetInstallPath(toolLibrary.Name, toolLibrary.Version);
var filePath = Path.Combine(packageDirectory, PathUtility.GetPathWithDirectorySeparator(runtimeAssembly.Path));
var filePath = Path.Combine(
packageDirectory,
PathUtility.GetPathWithDirectorySeparator(runtimeAssembly.Path));
return filePath;
}
@ -107,7 +124,7 @@ namespace Microsoft.DotNet.Cli.Utils
host = muxer.MuxerPath;
if (host == null)
{
throw new Exception("Unable to locate dotnet multiplexer");
throw new Exception(LocalizableStrings.UnableToLocateDotnetMultiplexer);
}
arguments.Add("exec");

View file

@ -30,7 +30,10 @@ namespace Microsoft.DotNet.Cli.Utils
var preferCliRuntimePath = Path.Combine(packageDirectory, "prefercliruntime");
Reporter.Verbose.WriteLine(
$"packagedcommandspecfactory: Looking for prefercliruntime file at `{preferCliRuntimePath}`");
string.Format(
LocalizableStrings.LookingForPreferCliRuntimeFile,
"packagedcommandspecfactory",
preferCliRuntimePath));
return File.Exists(preferCliRuntimePath);
}

View file

@ -10,6 +10,8 @@ namespace Microsoft.DotNet.Cli.Utils
{
public class ProjectDependenciesCommandResolver : ICommandResolver
{
private const string ProjectDependenciesCommandResolverName = "projectdependenciescommandresolver";
private static readonly CommandResolutionStrategy s_commandResolutionStrategy =
CommandResolutionStrategy.ProjectDependenciesPackage;
@ -36,14 +38,19 @@ namespace Microsoft.DotNet.Cli.Utils
public CommandSpec Resolve(CommandResolverArguments commandResolverArguments)
{
Reporter.Verbose.WriteLine($"projectdependenciescommandresolver: attempting to resolve {commandResolverArguments.CommandName}");
Reporter.Verbose.WriteLine(string.Format(
LocalizableStrings.AttemptingToResolve,
ProjectDependenciesCommandResolverName,
commandResolverArguments.CommandName));
if (commandResolverArguments.Framework == null
|| commandResolverArguments.ProjectDirectory == null
|| commandResolverArguments.Configuration == null
|| commandResolverArguments.CommandName == null)
{
Reporter.Verbose.WriteLine($"projectdependenciescommandresolver: invalid commandResolverArguments");
Reporter.Verbose.WriteLine(string.Format(
LocalizableStrings.InvalidCommandResolverArguments,
ProjectDependenciesCommandResolverName));
return null;
}
@ -79,7 +86,10 @@ namespace Microsoft.DotNet.Cli.Utils
if (project == null)
{
Reporter.Verbose.WriteLine($"projectdependenciescommandresolver: Didn't find a matching project {projectDirectory}.");
Reporter.Verbose.WriteLine(string.Format(
LocalizableStrings.DidNotFindAMatchingProject,
ProjectDependenciesCommandResolverName,
projectDirectory));
return null;
}
@ -87,7 +97,10 @@ namespace Microsoft.DotNet.Cli.Utils
if (!File.Exists(depsFilePath))
{
Reporter.Verbose.WriteLine($"projectdependenciescommandresolver: {depsFilePath} does not exist");
Reporter.Verbose.WriteLine(string.Format(
LocalizableStrings.DoesNotExist,
ProjectDependenciesCommandResolverName,
depsFilePath));
return null;
}
@ -95,7 +108,10 @@ namespace Microsoft.DotNet.Cli.Utils
if (!File.Exists(runtimeConfigPath))
{
Reporter.Verbose.WriteLine($"projectdependenciescommandresolver: {runtimeConfigPath} does not exist");
Reporter.Verbose.WriteLine(string.Format(
LocalizableStrings.DoesNotExist,
ProjectDependenciesCommandResolverName,
runtimeConfigPath));
return null;
}
@ -130,10 +146,15 @@ namespace Microsoft.DotNet.Cli.Utils
if (toolLibraries?.Count() > 1)
{
throw new InvalidOperationException($"Ambiguous command name: {commandName}");
throw new InvalidOperationException(string.Format(
LocalizableStrings.AmbiguousCommandName,
commandName));
}
Reporter.Verbose.WriteLine($"projectdependenciescommandresolver: tool library found {toolLibraries?.Count() > 0}");
Reporter.Verbose.WriteLine(string.Format(
LocalizableStrings.ToolLibraryFound,
ProjectDependenciesCommandResolverName,
toolLibraries?.Count() > 0));
return toolLibraries?.FirstOrDefault();
}

View file

@ -12,6 +12,8 @@ namespace Microsoft.DotNet.Cli.Utils
{
internal class ProjectFactory
{
private const string ProjectFactoryName = "projectfactory";
private IEnvironmentProvider _environment;
public ProjectFactory(IEnvironmentProvider environment)
@ -37,11 +39,17 @@ namespace Microsoft.DotNet.Cli.Utils
Path.Combine(AppContext.BaseDirectory, "MSBuild.dll") :
msBuildExePath;
Reporter.Verbose.WriteLine($"projectfactory: MSBUILD_EXE_PATH = {msBuildExePath}");
Reporter.Verbose.WriteLine(string.Format(
LocalizableStrings.MSBuildExePath,
ProjectFactoryName,
msBuildExePath));
string msBuildProjectPath = GetMSBuildProjPath(projectDirectory);
Reporter.Verbose.WriteLine($"projectfactory: MSBuild project path = {msBuildProjectPath}");
Reporter.Verbose.WriteLine(string.Format(
LocalizableStrings.MSBuildProjectPath,
ProjectFactoryName,
msBuildProjectPath));
if(msBuildProjectPath == null)
{
@ -72,8 +80,9 @@ namespace Microsoft.DotNet.Cli.Utils
}
else if (projectFiles.Count() > 1)
{
throw new InvalidOperationException(
$"Specify which project file to use because this '{projectDirectory}' contains more than one project file.");
throw new InvalidOperationException(string.Format(
LocalizableStrings.MultipleProjectFilesFound,
projectDirectory));
}
return projectFiles.First();

View file

@ -16,6 +16,8 @@ namespace Microsoft.DotNet.Cli.Utils
{
public class ProjectToolsCommandResolver : ICommandResolver
{
private const string ProjectToolsCommandResolverName = "projecttoolscommandresolver";
private static readonly NuGetFramework s_toolPackageFramework = FrameworkConstants.CommonFrameworks.NetCoreApp10;
private static readonly CommandResolutionStrategy s_commandResolutionStrategy =
@ -44,7 +46,9 @@ namespace Microsoft.DotNet.Cli.Utils
if (commandResolverArguments.CommandName == null
|| commandResolverArguments.ProjectDirectory == null)
{
Reporter.Verbose.WriteLine($"projecttoolscommandresolver: Invalid CommandResolverArguments");
Reporter.Verbose.WriteLine(string.Format(
LocalizableStrings.InvalidCommandResolverArguments,
ProjectToolsCommandResolverName));
return null;
}
@ -65,7 +69,8 @@ namespace Microsoft.DotNet.Cli.Utils
if (project == null)
{
Reporter.Verbose.WriteLine($"projecttoolscommandresolver: ProjectFactory did not find Project.");
Reporter.Verbose.WriteLine(string.Format(
LocalizableStrings.DidNotFindProject, ProjectToolsCommandResolverName));
return null;
}
@ -85,7 +90,10 @@ namespace Microsoft.DotNet.Cli.Utils
IEnumerable<string> args,
IProject project)
{
Reporter.Verbose.WriteLine($"projecttoolscommandresolver: resolving commandspec from {toolsLibraries.Count()} Tool Libraries.");
Reporter.Verbose.WriteLine(string.Format(
LocalizableStrings.ResolvingCommandSpec,
ProjectToolsCommandResolverName,
toolsLibraries.Count()));
foreach (var toolLibrary in toolsLibraries)
{
@ -101,7 +109,9 @@ namespace Microsoft.DotNet.Cli.Utils
}
}
Reporter.Verbose.WriteLine($"projecttoolscommandresolver: failed to resolve commandspec from library.");
Reporter.Verbose.WriteLine(string.Format(
LocalizableStrings.FailedToResolveCommandSpec,
ProjectToolsCommandResolverName));
return null;
}
@ -112,17 +122,26 @@ namespace Microsoft.DotNet.Cli.Utils
IEnumerable<string> args,
IProject project)
{
Reporter.Verbose.WriteLine($"projecttoolscommandresolver: Attempting to resolve command spec from tool {toolLibraryRange.Name}");
Reporter.Verbose.WriteLine(string.Format(
LocalizableStrings.AttemptingToResolveCommandSpec,
ProjectToolsCommandResolverName,
toolLibraryRange.Name));
var nuGetPathContext = NuGetPathContext.Create(project.ProjectRoot);
var nugetPackagesRoot = nuGetPathContext.UserPackageFolder;
Reporter.Verbose.WriteLine($"projecttoolscommandresolver: nuget packages root:\n{nugetPackagesRoot}");
Reporter.Verbose.WriteLine(string.Format(
LocalizableStrings.NuGetPackagesRoot,
ProjectToolsCommandResolverName,
nugetPackagesRoot));
var toolLockFile = GetToolLockFile(toolLibraryRange, nugetPackagesRoot);
Reporter.Verbose.WriteLine($"projecttoolscommandresolver: found tool lockfile at : {toolLockFile.Path}");
Reporter.Verbose.WriteLine(string.Format(
LocalizableStrings.FoundToolLockFile,
ProjectToolsCommandResolverName,
toolLockFile.Path));
var toolLibrary = toolLockFile.Targets
.FirstOrDefault(
@ -131,7 +150,9 @@ namespace Microsoft.DotNet.Cli.Utils
if (toolLibrary == null)
{
Reporter.Verbose.WriteLine($"projecttoolscommandresolver: library not found in lock file.");
Reporter.Verbose.WriteLine(string.Format(
LocalizableStrings.LibraryNotFoundInLockFile,
ProjectToolsCommandResolverName));
return null;
}
@ -142,7 +163,9 @@ namespace Microsoft.DotNet.Cli.Utils
var normalizedNugetPackagesRoot = PathUtility.EnsureNoTrailingDirectorySeparator(nugetPackagesRoot);
Reporter.Verbose.WriteLine($"projecttoolscommandresolver: attempting to create commandspec");
Reporter.Verbose.WriteLine(string.Format(
LocalizableStrings.AttemptingToCreateCommandSpec,
ProjectToolsCommandResolverName));
var commandSpec = _packagedCommandSpecFactory.CreateCommandSpecFromLibrary(
toolLibrary,
@ -156,7 +179,9 @@ namespace Microsoft.DotNet.Cli.Utils
if (commandSpec == null)
{
Reporter.Verbose.WriteLine($"projecttoolscommandresolver: commandSpec is null.");
Reporter.Verbose.WriteLine(string.Format(
LocalizableStrings.CommandSpecIsNull,
ProjectToolsCommandResolverName));
}
commandSpec?.AddEnvironmentVariablesFromProject(project);
@ -212,7 +237,9 @@ namespace Microsoft.DotNet.Cli.Utils
depsPathRoot,
toolLibrary.Name + FileNameSuffixes.DepsJson);
Reporter.Verbose.WriteLine($"projecttoolscommandresolver: expect deps.json at: {depsJsonPath}");
Reporter.Verbose.WriteLine(string.Format(
LocalizableStrings.ExpectDepsJsonAt,
depsJsonPath));
EnsureToolJsonDepsFileExists(toolLockFile, depsJsonPath, toolLibrary);
@ -235,7 +262,9 @@ namespace Microsoft.DotNet.Cli.Utils
string depsPath,
SingleProjectInfo toolLibrary)
{
Reporter.Verbose.WriteLine($"Generating deps.json at: {depsPath}");
Reporter.Verbose.WriteLine(string.Format(
LocalizableStrings.GeneratingDepsJson,
depsPath));
var dependencyContext = new DepsJsonBuilder()
.Build(toolLibrary, null, toolLockFile, s_toolPackageFramework, null);
@ -254,7 +283,9 @@ namespace Microsoft.DotNet.Cli.Utils
}
catch (Exception e)
{
Reporter.Verbose.WriteLine($"unable to generate deps.json, it may have been already generated: {e.Message}");
Reporter.Verbose.WriteLine(string.Format(
LocalizableStrings.UnableToGenerateDepsJson,
e.Message));
try
{
@ -262,7 +293,9 @@ namespace Microsoft.DotNet.Cli.Utils
}
catch (Exception e2)
{
Reporter.Verbose.WriteLine($"unable to delete temporary deps.json file: {e2.Message}");
Reporter.Verbose.WriteLine(string.Format(
LocalizableStrings.UnableToDeleteTemporaryDepsJson,
e2.Message));
}
}
}

View file

@ -59,7 +59,7 @@ namespace Microsoft.DotNet.Cli.Utils
var host = muxer.MuxerPath;
if (host == null)
{
throw new Exception("Unable to locate dotnet multiplexer");
throw new Exception(LocalizableStrings.UnableToLocateDotnetMultiplexer);
}
arguments.Add("exec");

View file

@ -7,6 +7,8 @@ namespace Microsoft.DotNet.Cli.Utils
{
public class PublishedPathCommandResolver : ICommandResolver
{
private const string PublishedPathCommandResolverName = "PublishedPathCommandResolver";
private readonly IEnvironmentProvider _environment;
private readonly IPublishedPathCommandSpecFactory _commandSpecFactory;
@ -39,14 +41,20 @@ namespace Microsoft.DotNet.Cli.Utils
var depsFilePath = Path.Combine(publishDirectory, $"{applicationName}.deps.json");
if (!File.Exists(depsFilePath))
{
Reporter.Verbose.WriteLine($"PublishedPathCommandResolver: {depsFilePath} does not exist");
Reporter.Verbose.WriteLine(string.Format(
LocalizableStrings.DoesNotExist,
PublishedPathCommandResolverName,
depsFilePath));
return null;
}
var runtimeConfigPath = Path.Combine(publishDirectory, $"{applicationName}.runtimeconfig.json");
if (!File.Exists(runtimeConfigPath))
{
Reporter.Verbose.WriteLine($"projectdependenciescommandresolver: {runtimeConfigPath} does not exist");
Reporter.Verbose.WriteLine(string.Format(
LocalizableStrings.DoesNotExist,
PublishedPathCommandResolverName,
runtimeConfigPath));
return null;
}
@ -62,7 +70,10 @@ namespace Microsoft.DotNet.Cli.Utils
{
if (!Directory.Exists(publishDirectory))
{
Reporter.Verbose.WriteLine($"publishedpathresolver: {publishDirectory} does not exist");
Reporter.Verbose.WriteLine(string.Format(
LocalizableStrings.DoesNotExist,
PublishedPathCommandResolverName,
publishDirectory));
return null;
}

View file

@ -35,7 +35,9 @@ namespace Microsoft.DotNet.Cli.Utils
var bestVersion = versionRange.FindBestMatch(availableToolVersions);
if (bestVersion == null)
{
throw new GracefulException($"Version for package `{packageId}` could not be resolved.");
throw new GracefulException(string.Format(
LocalizableStrings.VersionForPackageCouldNotBeResolved,
packageId));
}
return GetLockFilePath(packageId, bestVersion, framework);

View file

@ -8,11 +8,17 @@ namespace Microsoft.DotNet.Cli.Utils
{
}
public CommandUnknownException(string commandName) : base($"No executable found matching command \"{commandName}\"")
public CommandUnknownException(string commandName) : base(string.Format(
LocalizableStrings.NoExecutableFoundMatchingCommand,
commandName))
{
}
public CommandUnknownException(string commandName, Exception innerException) : base($"No executable found matching command \"{commandName}\"", innerException)
public CommandUnknownException(string commandName, Exception innerException) : base(
string.Format(
LocalizableStrings.NoExecutableFoundMatchingCommand,
commandName),
innerException)
{
}
}

View file

@ -21,8 +21,8 @@ namespace Microsoft.DotNet.Cli.Utils
public static void WaitForDebugger()
{
Console.WriteLine("Waiting for debugger to attach. Press ENTER to continue");
Console.WriteLine($"Process ID: {Process.GetCurrentProcess().Id}");
Console.WriteLine(LocalizableStrings.WaitingForDebuggerToAttach);
Console.WriteLine(string.Format(LocalizableStrings.ProcessId, Process.GetCurrentProcess().Id));
Console.ReadLine();
}
}

View file

@ -24,8 +24,8 @@ namespace Microsoft.DotNet.Cli.Utils
{
throw new GracefulException(string.Join(
Environment.NewLine,
$"File not found `{path}`.",
"The project may not have been restored or restore failed - run `dotnet restore`"));
string.Format(LocalizableStrings.FileNotFound, path),
LocalizableStrings.ProjectNotRestoredOrRestoreFailed));
}
return await ConcurrencyUtilities.ExecuteWithFileLockedAsync(

View file

@ -22,7 +22,7 @@ namespace Microsoft.DotNet.Cli.Utils
{
if (attemptsLeft < 1)
{
throw new InvalidOperationException("Could not access assets file.");
throw new InvalidOperationException(LocalizableStrings.CouldNotAccessAssetsFile);
}
attemptsLeft--;

View file

@ -0,0 +1,89 @@
namespace Microsoft.DotNet.Cli.Utils
{
internal class LocalizableStrings
{
public const string MalformedText = "Malformed command text '{0}'";
public const string BuildOutputPathDoesNotExist = "outputpathresolver: {0} does not exist";
public const string AttemptingToFindCommand = "{0}: attempting to find command {1} in {2}";
public const string FailedToFindToolAssembly = "{0}: failed to find toolAssembly for {1}";
public const string FailedToFindCommandPath = "{0}: failed to find commandPath {1}";
public const string UnableToLocateDotnetMultiplexer = "Unable to locate dotnet multiplexer";
public const string LookingForPreferCliRuntimeFile = "{0}: Looking for prefercliruntime file at `{1}`";
public const string AttemptingToResolve = "{0}: attempting to resolve {1}";
public const string DidNotFindAMatchingProject = "{0}: Did not find a matching project {1}.";
public const string InvalidCommandResolverArguments = "{0}: invalid commandResolverArguments";
public const string DoesNotExist = "{0}: {1} does not exist";
public const string AmbiguousCommandName = "Ambiguous command name: {0}";
public const string ToolLibraryFound = "{0}: tool library found {1}";
public const string MSBuildExePath = "{0}: MSBUILD_EXE_PATH = {1}";
public const string MSBuildProjectPath = "{0}: MSBuild project path = {1}";
public const string MultipleProjectFilesFound = "Specify which project file to use because this '{0}' contains more than one project file.";
public const string DidNotFindProject = "{0}: ProjectFactory did not find Project.";
public const string ResolvingCommandSpec = "{0}: resolving commandspec from {1} Tool Libraries.";
public const string FailedToResolveCommandSpec = "{0}: failed to resolve commandspec from library.";
public const string AttemptingToResolveCommandSpec = "{0}: Attempting to resolve command spec from tool {1}";
public const string NuGetPackagesRoot = "{0}: nuget packages root:\n{1}";
public const string FoundToolLockFile = "{0}: found tool lockfile at : {1}";
public const string LibraryNotFoundInLockFile = "{0}: library not found in lock file.";
public const string AttemptingToCreateCommandSpec = "{0}: attempting to create commandspec";
public const string CommandSpecIsNull = "{0}: commandSpec is null.";
public const string ExpectDepsJsonAt = "{0}: expect deps.json at: {1}";
public const string GeneratingDepsJson = "Generating deps.json at: {0}";
public const string UnableToGenerateDepsJson = "unable to generate deps.json, it may have been already generated: {0}";
public const string UnableToDeleteTemporaryDepsJson = "unable to delete temporary deps.json file: {0}";
public const string VersionForPackageCouldNotBeResolved = "Version for package `{0}` could not be resolved.";
public const string FileNotFound = "File not found `{0}`.";
public const string ProjectNotRestoredOrRestoreFailed = "The project may not have been restored or restore failed - run `dotnet restore`";
public const string NoExecutableFoundMatchingCommand = "No executable found matching command \"{0}\"";
public const string WaitingForDebuggerToAttach = "Waiting for debugger to attach. Press ENTER to continue";
public const string ProcessId = "Process ID: {0}";
public const string CouldNotAccessAssetsFile = "Could not access assets file.";
public const string DotNetCommandLineTools = ".NET Command Line Tools";
public const string WriteLineForwarderSetPreviously = "WriteLine forwarder set previously";
public const string AlreadyCapturingStream = "Already capturing stream!";
public const string RunningFileNameArguments = "Running {0} {1}";
public const string ProcessExitedWithCode = "< {0} exited with {1} in {2} ms.";
public const string UnableToInvokeMemberNameAfterCommand = "Unable to invoke {0} after the command has been run";
}
}

View file

@ -26,7 +26,7 @@ namespace Microsoft.DotNet.Cli.Utils
{
if (_muxerPath == null)
{
throw new InvalidOperationException("Unable to locate dotnet multiplexer");
throw new InvalidOperationException(LocalizableStrings.UnableToLocateDotnetMultiplexer);
}
return _muxerPath;
}

View file

@ -4,12 +4,15 @@ namespace Microsoft.DotNet.Cli.Utils
{
public class Product
{
public static readonly string LongName = ".NET Command Line Tools";
public static readonly string LongName = LocalizableStrings.DotNetCommandLineTools;
public static readonly string Version = GetProductVersion();
private static string GetProductVersion()
{
var attr = typeof(Product).GetTypeInfo().Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
var attr = typeof(Product)
.GetTypeInfo()
.Assembly
.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
return attr?.InformationalVersion;
}
}

View file

@ -118,7 +118,7 @@ namespace Microsoft.DotNet.Cli.Utils
{
if (_writeLine != null)
{
throw new InvalidOperationException("WriteLine forwarder set previously");
throw new InvalidOperationException(LocalizableStrings.WriteLineForwarderSetPreviously);
}
}
@ -126,7 +126,7 @@ namespace Microsoft.DotNet.Cli.Utils
{
if (_capture != null)
{
throw new InvalidOperationException("Already capturing stream!");
throw new InvalidOperationException(LocalizableStrings.AlreadyCapturingStream);
}
}
}