diff --git a/src/dotnet/Properties/AssemblyInfo.cs b/src/dotnet/Properties/AssemblyInfo.cs
index edc4c971f..d7ae131d6 100644
--- a/src/dotnet/Properties/AssemblyInfo.cs
+++ b/src/dotnet/Properties/AssemblyInfo.cs
@@ -16,3 +16,4 @@ using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("dotnet-sln-list.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("dotnet-sln-remove.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("dotnet-msbuild.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
+[assembly: InternalsVisibleTo("dotnet-run.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
diff --git a/src/dotnet/commands/dotnet-run/LocalizableStrings.resx b/src/dotnet/commands/dotnet-run/LocalizableStrings.resx
index 976312b28..8cab1941e 100644
--- a/src/dotnet/commands/dotnet-run/LocalizableStrings.resx
+++ b/src/dotnet/commands/dotnet-run/LocalizableStrings.resx
@@ -196,4 +196,7 @@ The current {1} is '{2}'.
An error was encountered when reading launchSettings.json.
{0}
+
+ '{0}' is not a valid project file.
+
\ No newline at end of file
diff --git a/src/dotnet/commands/dotnet-run/RunCommand.cs b/src/dotnet/commands/dotnet-run/RunCommand.cs
index d760a8690..e4af4a2a0 100644
--- a/src/dotnet/commands/dotnet-run/RunCommand.cs
+++ b/src/dotnet/commands/dotnet-run/RunCommand.cs
@@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.Build.Evaluation;
+using Microsoft.Build.Exceptions;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Tools;
using Microsoft.DotNet.Tools.MSBuild;
@@ -39,17 +40,26 @@ namespace Microsoft.DotNet.Tools.Run
EnsureProjectIsBuilt();
}
- ICommand runCommand = GetRunCommand();
- int launchSettingsApplicationResult = ApplyLaunchProfileSettingsIfNeeded(ref runCommand);
-
- if (launchSettingsApplicationResult != 0)
+ try
{
- return launchSettingsApplicationResult;
- }
+ ICommand runCommand = GetRunCommand();
+ int launchSettingsApplicationResult = ApplyLaunchProfileSettingsIfNeeded(ref runCommand);
- return runCommand
- .Execute()
- .ExitCode;
+ if (launchSettingsApplicationResult != 0)
+ {
+ return launchSettingsApplicationResult;
+ }
+
+ return runCommand
+ .Execute()
+ .ExitCode;
+ }
+ catch (InvalidProjectFileException e)
+ {
+ throw new GracefulException(
+ string.Format(LocalizableStrings.RunCommandSpecifiecFileIsNotAValidProject, Project),
+ e);
+ }
}
public RunCommand(string configuration,
diff --git a/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.cs.xlf b/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.cs.xlf
index 8577240b2..5563eace5 100644
--- a/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.cs.xlf
+++ b/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.cs.xlf
@@ -136,6 +136,11 @@ Aktuální {1} je {2}.
{0}
+
+ '{0}' is not a valid project file.
+ '{0}' is not a valid project file.
+
+