Fixing restore so that it respects the verbosity param. The problem was that ConsoleLoggerParameters was overwritting whatever was coming through the command line.
This commit is contained in:
parent
e157c4bd09
commit
357fd3daf1
3 changed files with 51 additions and 7 deletions
|
@ -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);
|
||||
|
|
|
@ -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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue