Merge pull request #9734 from peterhuene/fix-run-output
Suppress output from `dotnet run` when using quiet verbosity level.
This commit is contained in:
commit
fdfc1b668b
2 changed files with 31 additions and 1 deletions
|
@ -26,6 +26,10 @@ namespace Microsoft.DotNet.Tools.Run
|
|||
|
||||
private List<string> _args;
|
||||
private bool ShouldBuild => !NoBuild;
|
||||
private bool HasQuietVerbosity =>
|
||||
RestoreArgs.All(arg => !arg.StartsWith("-verbosity:", StringComparison.Ordinal) ||
|
||||
arg.Equals("-verbosity:q", StringComparison.Ordinal) ||
|
||||
arg.Equals("-verbosity:quiet", StringComparison.Ordinal));
|
||||
|
||||
public string LaunchProfile { get; private set; }
|
||||
public bool NoLaunchProfile { get; private set; }
|
||||
|
@ -114,7 +118,10 @@ namespace Microsoft.DotNet.Tools.Run
|
|||
var launchSettingsPath = Path.Combine(buildPathContainer, "Properties", "launchSettings.json");
|
||||
if (File.Exists(launchSettingsPath))
|
||||
{
|
||||
if (!HasQuietVerbosity) {
|
||||
Reporter.Output.WriteLine(string.Format(LocalizableStrings.UsingLaunchSettingsFromMessage, launchSettingsPath));
|
||||
}
|
||||
|
||||
string profileName = string.IsNullOrEmpty(LaunchProfile) ? LocalizableStrings.DefaultLaunchProfileDisplayName : LaunchProfile;
|
||||
|
||||
try
|
||||
|
|
|
@ -343,6 +343,7 @@ namespace Microsoft.DotNet.Cli.Run.Tests
|
|||
.WithSourceFiles();
|
||||
|
||||
var testProjectDirectory = testInstance.Root.FullName;
|
||||
var launchSettingsPath = Path.Combine(testProjectDirectory, "Properties", "launchSettings.json");
|
||||
|
||||
new RestoreCommand()
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
|
@ -359,6 +360,28 @@ namespace Microsoft.DotNet.Cli.Run.Tests
|
|||
.ExecuteWithCapturedOutput();
|
||||
|
||||
cmd.Should().Pass()
|
||||
.And.NotHaveStdOutContaining(string.Format(LocalizableStrings.UsingLaunchSettingsFromMessage, launchSettingsPath))
|
||||
.And.HaveStdOutContaining("First");
|
||||
|
||||
cmd.StdErr.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItPrintsUsingLaunchSettingsMessageWhenNotQuiet()
|
||||
{
|
||||
var testInstance = TestAssets.Get("AppWithLaunchSettings")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles();
|
||||
|
||||
var testProjectDirectory = testInstance.Root.FullName;
|
||||
var launchSettingsPath = Path.Combine(testProjectDirectory, "Properties", "launchSettings.json");
|
||||
|
||||
var cmd = new RunCommand()
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
.ExecuteWithCapturedOutput("-v:m");
|
||||
|
||||
cmd.Should().Pass()
|
||||
.And.HaveStdOutContaining(string.Format(LocalizableStrings.UsingLaunchSettingsFromMessage, launchSettingsPath))
|
||||
.And.HaveStdOutContaining("First");
|
||||
|
||||
cmd.StdErr.Should().BeEmpty();
|
||||
|
|
Loading…
Reference in a new issue