Handling an exception that happens when dotnet run is invoked with a file that is not a valid project file. We catch that exception and re-throw it as a GracefulException.
This commit is contained in:
parent
f4d884a03d
commit
37f531be4c
18 changed files with 127 additions and 9 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Reference in a new issue