diff --git a/src/dotnet/commands/dotnet-migrate/MigrateCommand.cs b/src/dotnet/commands/dotnet-migrate/MigrateCommand.cs index 900cb6567..cc5086ab2 100644 --- a/src/dotnet/commands/dotnet-migrate/MigrateCommand.cs +++ b/src/dotnet/commands/dotnet-migrate/MigrateCommand.cs @@ -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); diff --git a/src/dotnet/commands/dotnet-migrate/Program.cs b/src/dotnet/commands/dotnet-migrate/Program.cs index a60660ab8..9e5b6b84b 100644 --- a/src/dotnet/commands/dotnet-migrate/Program.cs +++ b/src/dotnet/commands/dotnet-migrate/Program.cs @@ -69,6 +69,7 @@ namespace Microsoft.DotNet.Tools.Migrate #else Reporter.Error.WriteLine(ex.Message); #endif + Reporter.Error.WriteLine("Migration failed."); return 1; } }