Merge pull request #6627 from livarcocc/fix_restore_verbosity

Fixing restore so that it respects the verbosity param.
This commit is contained in:
Livar 2017-05-18 15:39:05 -07:00 committed by GitHub
commit 6647eddf24
3 changed files with 51 additions and 7 deletions

View file

@ -34,10 +34,14 @@ namespace Microsoft.DotNet.Tools.Restore
var msbuildArgs = new List<string>
{
"/NoLogo",
"/t:Restore",
"/ConsoleLoggerParameters:Verbosity=Minimal"
"/t:Restore"
};
if (!parsedRestore.HasOption("verbosity"))
{
msbuildArgs.Add("/ConsoleLoggerParameters:Verbosity=Minimal");
}
msbuildArgs.AddRange(parsedRestore.OptionValuesToBeForwarded());
msbuildArgs.AddRange(parsedRestore.Arguments);

View file

@ -10,7 +10,11 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
{
public class GivenDotnetRestoreInvocation
{
const string ExpectedPrefix = "exec <msbuildpath> /m /v:m /NoLogo /t:Restore /ConsoleLoggerParameters:Verbosity=Minimal";
private const string ExpectedPrefix =
"exec <msbuildpath> /m /v:m /NoLogo /t:Restore";
private string ExpectedPrefixWithConsoleLoggerParamaters =
$"{ExpectedPrefix} /ConsoleLoggerParameters:Verbosity=Minimal";
[Theory]
[InlineData(new string[] { }, "")]
@ -26,15 +30,26 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
[InlineData(new string[] { "--no-cache" }, "/p:RestoreNoCache=true")]
[InlineData(new string[] { "--ignore-failed-sources" }, "/p:RestoreIgnoreFailedSources=true")]
[InlineData(new string[] { "--no-dependencies" }, "/p:RestoreRecursive=false")]
[InlineData(new string[] { "-v", "minimal" }, @"/verbosity:minimal")]
[InlineData(new string[] { "--verbosity", "minimal" }, @"/verbosity:minimal")]
public void MsbuildInvocationIsCorrect(string[] args, string expectedAdditionalArgs)
public void MsbuildInvocationWithConsoleLoggerParametersIsCorrect(string[] args, string expectedAdditionalArgs)
{
expectedAdditionalArgs = (string.IsNullOrEmpty(expectedAdditionalArgs) ? "" : $" {expectedAdditionalArgs}");
var msbuildPath = "<msbuildpath>";
RestoreCommand.FromArgs(args, msbuildPath)
.GetProcessStartInfo().Arguments.Should().Be($"{ExpectedPrefix}{expectedAdditionalArgs}");
.GetProcessStartInfo().Arguments
.Should().Be($"{ExpectedPrefixWithConsoleLoggerParamaters}{expectedAdditionalArgs}");
}
[InlineData(new string[] { "-v", "minimal" }, @"/verbosity:minimal")]
[InlineData(new string[] { "--verbosity", "minimal" }, @"/verbosity:minimal")]
public void MsbuildInvocationWithVerbosityIsCorrect(string[] args, string expectedAdditionalArgs)
{
expectedAdditionalArgs = (string.IsNullOrEmpty(expectedAdditionalArgs) ? "" : $" {expectedAdditionalArgs}");
var msbuildPath = "<msbuildpath>";
RestoreCommand.FromArgs(args, msbuildPath)
.GetProcessStartInfo().Arguments
.Should().Be($"{ExpectedPrefix}{expectedAdditionalArgs}");
}
}
}

View file

@ -89,5 +89,30 @@ namespace Microsoft.DotNet.Restore.Tests
Directory.Exists(fullPath).Should().BeTrue();
Directory.EnumerateFiles(fullPath, "*.dll", SearchOption.AllDirectories).Count().Should().BeGreaterThan(0);
}
[Fact]
public void ItRestoresWithTheSpecifiedVerbosity()
{
var rootPath = TestAssets.CreateTestDirectory().FullName;
string dir = "pkgs";
string fullPath = Path.GetFullPath(Path.Combine(rootPath, dir));
string newArgs = $"console -o \"{rootPath}\" --no-restore";
new NewCommandShim()
.WithWorkingDirectory(rootPath)
.Execute(newArgs)
.Should()
.Pass();
string args = $"--configfile {RepoRootNuGetConfig} --packages \"{dir}\" --verbosity quiet";
new RestoreCommand()
.WithWorkingDirectory(rootPath)
.ExecuteWithCapturedOutput(args)
.Should()
.Pass()
.And.NotHaveStdErr()
.And.NotHaveStdOut();
}
}
}