Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit dcc99d6

Browse files
author
Peter Huene
committed
Make restore performed by run command default to nologo and quiet.
This commit changes the run command such that it will now be `/nologo` and `/verbosity:quiet` (by default) for the restore operation even if a target framework is specified. When a target framework is specified, a separate restore operation is performed that does not pass `/nologo` and the default verbosity is used. The fix is to ensure that the arguments used for the restore operation match those that are used for the build operation. Fixes #8118.
1 parent d38c600 commit dcc99d6

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

src/dotnet/commands/dotnet-run/RunCommand.cs

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,24 +146,40 @@ private int ApplyLaunchProfileSettingsIfNeeded(ref ICommand runCommand)
146146

147147
private void EnsureProjectIsBuilt()
148148
{
149-
List<string> buildArgs = new List<string>();
150-
151-
buildArgs.Add(Project);
152-
153-
buildArgs.Add("/nologo");
154-
buildArgs.Add("/verbosity:quiet");
155-
156-
buildArgs.AddRange(RestoreArgs);
149+
var restoreArgs = GetRestoreArguments();
157150

158151
var buildResult =
159-
new RestoringCommand(buildArgs, RestoreArgs, new [] { Project }, NoRestore).Execute();
152+
new RestoringCommand(
153+
restoreArgs.Prepend(Project),
154+
restoreArgs,
155+
new [] { Project },
156+
NoRestore
157+
).Execute();
158+
160159
if (buildResult != 0)
161160
{
162161
Reporter.Error.WriteLine();
163162
throw new GracefulException(LocalizableStrings.RunCommandException);
164163
}
165164
}
166165

166+
private List<string> GetRestoreArguments()
167+
{
168+
List<string> args = new List<string>()
169+
{
170+
"/nologo"
171+
};
172+
173+
if (!RestoreArgs.Any(a => a.StartsWith("/verbosity:")))
174+
{
175+
args.Add("/verbosity:quiet");
176+
}
177+
178+
args.AddRange(RestoreArgs);
179+
180+
return args;
181+
}
182+
167183
private ICommand GetRunCommand()
168184
{
169185
var globalProperties = new Dictionary<string, string>

test/dotnet-run.Tests/GivenDotnetRunRunsCsProj.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public void ItCanRunAMSBuildProjectWhenSpecifyingAFramework()
152152
.WithWorkingDirectory(testProjectDirectory)
153153
.ExecuteWithCapturedOutput("--framework netcoreapp2.1")
154154
.Should().Pass()
155-
.And.HaveStdOutContaining("Hello World!");
155+
.And.HaveStdOut("Hello World!");
156156
}
157157

158158
[Fact]

0 commit comments

Comments
 (0)