Add a better error message for 'dotnet run3' when it is unable to find a RunCommand property.

This commit is contained in:
Eric Erhardt 2016-09-14 16:27:52 -05:00
parent f9953c1e68
commit 3026eb9d35

View file

@ -13,10 +13,6 @@ namespace Microsoft.DotNet.Tools.Run
{ {
public partial class Run3Command public partial class Run3Command
{ {
private const string RunCommandPropName = "RunCommand";
private const string RunArgumentsPropName = "RunArguments";
private const string RunWorkingDirectoryPropName = "RunWorkingDirectory";
public string Configuration { get; set; } public string Configuration { get; set; }
public string Project { get; set; } public string Project { get; set; }
public IReadOnlyList<string> Args { get; set; } public IReadOnlyList<string> Args { get; set; }
@ -75,14 +71,19 @@ namespace Microsoft.DotNet.Tools.Run
ProjectInstance projectInstance = new ProjectInstance(Project, globalProperties, null); ProjectInstance projectInstance = new ProjectInstance(Project, globalProperties, null);
string runProgram = projectInstance.GetPropertyValue(RunCommandPropName); string runProgram = projectInstance.GetPropertyValue("RunCommand");
if (string.IsNullOrEmpty(runProgram)) if (string.IsNullOrEmpty(runProgram))
{ {
throw new InvalidOperationException($"The property named '{RunCommandPropName}' does not have a value in your project. Please ensure 'dotnet run' supports this project."); string outputType = projectInstance.GetPropertyValue("OutputType");
throw new GracefulException(string.Join(Environment.NewLine,
"Unable to run your project.",
"Please ensure you have a runnable project type and ensure 'dotnet run' supports this project.",
$"The current OutputType is '{outputType}'."));
} }
string runArguments = projectInstance.GetPropertyValue(RunArgumentsPropName); string runArguments = projectInstance.GetPropertyValue("RunArguments");
string runWorkingDirectory = projectInstance.GetPropertyValue(RunWorkingDirectoryPropName); string runWorkingDirectory = projectInstance.GetPropertyValue("RunWorkingDirectory");
string fullArguments = runArguments; string fullArguments = runArguments;
if (_args.Any()) if (_args.Any())