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
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.IO;
|
||||
using FluentAssertions;
|
||||
using Microsoft.DotNet.TestFramework;
|
||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Run.Tests
|
||||
{
|
||||
public class GivenThatWeCanPassNonProjectFilesToDotnetRun : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public void ItFailsWithAnAppropriateErrorMessage()
|
||||
{
|
||||
var projectDirectory = TestAssets
|
||||
.Get("SlnFileWithNoProjectReferences")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root
|
||||
.FullName;
|
||||
|
||||
var slnFullPath = Path.Combine(projectDirectory, "SlnFileWithNoProjectReferences.sln");
|
||||
|
||||
new RunCommand()
|
||||
.ExecuteWithCapturedOutput($"-p {slnFullPath}")
|
||||
.Should().Fail()
|
||||
.And.HaveStdErrContaining(
|
||||
string.Format(
|
||||
Microsoft.DotNet.Tools.Run.LocalizableStrings.RunCommandSpecifiecFileIsNotAValidProject,
|
||||
slnFullPath));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in a new issue