Improve error messages for the migrate command

https://github.com/dotnet/cli/issues/4313
This commit is contained in:
Justin Goshi 2016-10-10 15:38:25 -07:00
parent 93166dd77c
commit 48ae5d17ac
2 changed files with 10 additions and 6 deletions

View file

@ -195,21 +195,24 @@ namespace Microsoft.DotNet.Tools.Migrate
else if (projectArg.EndsWith(GlobalSettings.FileName, StringComparison.OrdinalIgnoreCase))
{
projects = GetProjectsFromGlobalJson(projectArg);
if (!projects.Any())
{
throw new Exception("Unable to find any projects in global.json");
}
}
else if (Directory.Exists(projectArg))
{
projects = Directory.EnumerateFiles(projectArg, Project.FileName, SearchOption.AllDirectories);
if (!projects.Any())
{
throw new Exception($"No project.json file found in '{projectArg}'");
}
}
else
{
throw new Exception($"Invalid project argument - '{projectArg}' is not a project.json or a global.json file and a directory named '{projectArg}' doesn't exist.");
}
if (!projects.Any())
{
throw new Exception($"Invalid project argument - Unable to find any projects in global.json or directory '{projectArg}'");
}
foreach(var project in projects)
{
yield return GetProjectJsonPath(project);

View file

@ -69,6 +69,7 @@ namespace Microsoft.DotNet.Tools.Migrate
#else
Reporter.Error.WriteLine(ex.Message);
#endif
Reporter.Error.WriteLine("Migration failed.");
return 1;
}
}