diff --git a/src/dotnet/commands/dotnet-run/RunCommand.cs b/src/dotnet/commands/dotnet-run/RunCommand.cs index e4af4a2a0..8534c39d1 100644 --- a/src/dotnet/commands/dotnet-run/RunCommand.cs +++ b/src/dotnet/commands/dotnet-run/RunCommand.cs @@ -146,17 +146,16 @@ namespace Microsoft.DotNet.Tools.Run private void EnsureProjectIsBuilt() { - List buildArgs = new List(); - - buildArgs.Add(Project); - - buildArgs.Add("/nologo"); - buildArgs.Add("/verbosity:quiet"); - - buildArgs.AddRange(RestoreArgs); + var restoreArgs = GetRestoreArguments(); var buildResult = - new RestoringCommand(buildArgs, RestoreArgs, new [] { Project }, NoRestore).Execute(); + new RestoringCommand( + restoreArgs.Prepend(Project), + restoreArgs, + new [] { Project }, + NoRestore + ).Execute(); + if (buildResult != 0) { Reporter.Error.WriteLine(); @@ -164,6 +163,23 @@ namespace Microsoft.DotNet.Tools.Run } } + private List GetRestoreArguments() + { + List args = new List() + { + "/nologo" + }; + + if (!RestoreArgs.Any(a => a.StartsWith("/verbosity:"))) + { + args.Add("/verbosity:quiet"); + } + + args.AddRange(RestoreArgs); + + return args; + } + private ICommand GetRunCommand() { var globalProperties = new Dictionary diff --git a/test/dotnet-run.Tests/GivenDotnetRunRunsCsProj.cs b/test/dotnet-run.Tests/GivenDotnetRunRunsCsProj.cs index 6f3f14e65..35660db73 100644 --- a/test/dotnet-run.Tests/GivenDotnetRunRunsCsProj.cs +++ b/test/dotnet-run.Tests/GivenDotnetRunRunsCsProj.cs @@ -152,7 +152,7 @@ namespace Microsoft.DotNet.Cli.Run.Tests .WithWorkingDirectory(testProjectDirectory) .ExecuteWithCapturedOutput("--framework netcoreapp2.1") .Should().Pass() - .And.HaveStdOutContaining("Hello World!"); + .And.HaveStdOut("Hello World!"); } [Fact]