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));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,11 +6,15 @@
|
|||
<RuntimeFrameworkVersion>$(CLI_SharedFrameworkVersion)</RuntimeFrameworkVersion>
|
||||
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
|
||||
<AssemblyName>dotnet-run.Tests</AssemblyName>
|
||||
<AssemblyOriginatorKeyFile>../../tools/Key.snk</AssemblyOriginatorKeyFile>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
|
||||
<AssetTargetFallback>$(AssetTargetFallback);dotnet5.4;portable-net451+win8</AssetTargetFallback>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Microsoft.DotNet.Tools.Tests.Utilities\Microsoft.DotNet.Tools.Tests.Utilities.csproj" />
|
||||
<ProjectReference Include="..\..\src\dotnet\dotnet.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue