From 3026eb9d35695e16e01b192e68d0db90bc1e1628 Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Wed, 14 Sep 2016 16:27:52 -0500 Subject: [PATCH] Add a better error message for 'dotnet run3' when it is unable to find a RunCommand property. --- src/dotnet/commands/dotnet-run3/Run3Command.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/dotnet/commands/dotnet-run3/Run3Command.cs b/src/dotnet/commands/dotnet-run3/Run3Command.cs index b72081672..222853395 100644 --- a/src/dotnet/commands/dotnet-run3/Run3Command.cs +++ b/src/dotnet/commands/dotnet-run3/Run3Command.cs @@ -13,10 +13,6 @@ namespace Microsoft.DotNet.Tools.Run { 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 Project { get; set; } public IReadOnlyList Args { get; set; } @@ -75,14 +71,19 @@ namespace Microsoft.DotNet.Tools.Run ProjectInstance projectInstance = new ProjectInstance(Project, globalProperties, null); - string runProgram = projectInstance.GetPropertyValue(RunCommandPropName); + string runProgram = projectInstance.GetPropertyValue("RunCommand"); 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 runWorkingDirectory = projectInstance.GetPropertyValue(RunWorkingDirectoryPropName); + string runArguments = projectInstance.GetPropertyValue("RunArguments"); + string runWorkingDirectory = projectInstance.GetPropertyValue("RunWorkingDirectory"); string fullArguments = runArguments; if (_args.Any())