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

Commit 05b0b64

Browse files
committed
Pass nologo to MSBuild in 'add package' command
Fixes #6534
1 parent 7f50f32 commit 05b0b64

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/dotnet/commands/dotnet-add/dotnet-add-package/Program.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ private void GetProjectDependencyGraph(string projectFilePath, string dgFilePath
100100
// Turn off restore for Dotnet cli tool references so that we do not generate extra dg specs
101101
args.Add($"/p:RestoreDotnetCliToolReferences=false");
102102

103+
// Output should not include MSBuild version header
104+
args.Add("/nologo");
105+
103106
var result = new MSBuildForwardingApp(args).Execute();
104107

105108
if (result != 0)

test/dotnet-add-package.Tests/GivenDotnetPackageAdd.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,27 @@ public void WhenValidPackageIsPassedWithFrameworkItGetsAdded()
116116
cmd.StdErr.Should().BeEmpty();
117117
}
118118

119+
[Fact]
120+
public void WhenValidPackageIsPassedMSBuildDoesNotPrintVersionHeader()
121+
{
122+
var testAsset = "TestAppSimple";
123+
var projectDirectory = TestAssets
124+
.Get(testAsset)
125+
.CreateInstance()
126+
.WithSourceFiles()
127+
.Root
128+
.FullName;
129+
130+
var packageName = "Newtonsoft.Json";
131+
var packageVersion = "9.0.1";
132+
var cmd = new DotnetCommand()
133+
.WithWorkingDirectory(projectDirectory)
134+
.ExecuteWithCapturedOutput($"add package {packageName} --version {packageVersion}");
135+
cmd.Should().Pass();
136+
cmd.StdOut.Should().NotContain("Microsoft (R) Build Engine version");
137+
cmd.StdErr.Should().BeEmpty();
138+
}
139+
119140
[Fact]
120141
public void WhenMultiplePackagesArePassedCommandFails()
121142
{

0 commit comments

Comments
 (0)