Hide restore output of first-run experience (#4740)
* Fix 4066 * Merge Conflict * Move fix to the DotNetCommandFactory * More normalization The `\r\n` issue is oddly non-deterministic. This change did not affect the message endings and yet CI started failing. Normalizing both string should have the desired result...
This commit is contained in:
parent
7b0117ac85
commit
b47d728516
6 changed files with 29 additions and 9 deletions
|
@ -166,12 +166,14 @@ namespace Microsoft.DotNet.Cli.Utils
|
||||||
public ICommand CaptureStdErr()
|
public ICommand CaptureStdErr()
|
||||||
{
|
{
|
||||||
_stdErr.Capture();
|
_stdErr.Capture();
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICommand CaptureStdOut()
|
public ICommand CaptureStdOut()
|
||||||
{
|
{
|
||||||
_stdOut.Capture();
|
_stdOut.Capture();
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -160,7 +160,7 @@ namespace Microsoft.DotNet.Cli.Utils
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return new CommandResult(
|
return new CommandResult(
|
||||||
this._process.StartInfo,
|
_process.StartInfo,
|
||||||
exitCode,
|
exitCode,
|
||||||
_stdOut?.CapturedOutput,
|
_stdOut?.CapturedOutput,
|
||||||
_stdErr?.CapturedOutput);
|
_stdErr?.CapturedOutput);
|
||||||
|
|
|
@ -11,9 +11,13 @@ namespace Microsoft.DotNet.Configurer
|
||||||
public class NuGetCachePrimer : INuGetCachePrimer
|
public class NuGetCachePrimer : INuGetCachePrimer
|
||||||
{
|
{
|
||||||
private readonly ICommandFactory _commandFactory;
|
private readonly ICommandFactory _commandFactory;
|
||||||
|
|
||||||
private readonly IDirectory _directory;
|
private readonly IDirectory _directory;
|
||||||
|
|
||||||
private readonly IFile _file;
|
private readonly IFile _file;
|
||||||
|
|
||||||
private readonly INuGetPackagesArchiver _nugetPackagesArchiver;
|
private readonly INuGetPackagesArchiver _nugetPackagesArchiver;
|
||||||
|
|
||||||
private readonly INuGetCacheSentinel _nuGetCacheSentinel;
|
private readonly INuGetCacheSentinel _nuGetCacheSentinel;
|
||||||
|
|
||||||
public NuGetCachePrimer(
|
public NuGetCachePrimer(
|
||||||
|
@ -36,9 +40,13 @@ namespace Microsoft.DotNet.Configurer
|
||||||
IFile file)
|
IFile file)
|
||||||
{
|
{
|
||||||
_commandFactory = commandFactory;
|
_commandFactory = commandFactory;
|
||||||
|
|
||||||
_directory = directory;
|
_directory = directory;
|
||||||
|
|
||||||
_nugetPackagesArchiver = nugetPackagesArchiver;
|
_nugetPackagesArchiver = nugetPackagesArchiver;
|
||||||
|
|
||||||
_nuGetCacheSentinel = nuGetCacheSentinel;
|
_nuGetCacheSentinel = nuGetCacheSentinel;
|
||||||
|
|
||||||
_file = file;
|
_file = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,12 +72,14 @@ namespace Microsoft.DotNet.Configurer
|
||||||
using (var temporaryDotnetNewDirectory = _directory.CreateTemporaryDirectory())
|
using (var temporaryDotnetNewDirectory = _directory.CreateTemporaryDirectory())
|
||||||
{
|
{
|
||||||
var workingDirectory = temporaryDotnetNewDirectory.DirectoryPath;
|
var workingDirectory = temporaryDotnetNewDirectory.DirectoryPath;
|
||||||
|
|
||||||
var createProjectSucceeded = CreateTemporaryProject(workingDirectory);
|
var createProjectSucceeded = CreateTemporaryProject(workingDirectory);
|
||||||
|
|
||||||
if (createProjectSucceeded)
|
if (createProjectSucceeded)
|
||||||
{
|
{
|
||||||
var restoreProjectSucceeded =
|
var restoreProjectSucceeded =
|
||||||
RestoreTemporaryProject(extractedPackagesArchiveDirectory, workingDirectory);
|
RestoreTemporaryProject(extractedPackagesArchiveDirectory, workingDirectory);
|
||||||
|
|
||||||
if (restoreProjectSucceeded)
|
if (restoreProjectSucceeded)
|
||||||
{
|
{
|
||||||
_nuGetCacheSentinel.CreateIfNotExists();
|
_nuGetCacheSentinel.CreateIfNotExists();
|
||||||
|
@ -93,8 +103,8 @@ namespace Microsoft.DotNet.Configurer
|
||||||
|
|
||||||
private bool RunCommand(string commandToExecute, IEnumerable<string> args, string workingDirectory)
|
private bool RunCommand(string commandToExecute, IEnumerable<string> args, string workingDirectory)
|
||||||
{
|
{
|
||||||
var command = _commandFactory
|
var command = _commandFactory
|
||||||
.Create(commandToExecute, args)
|
.Create(commandToExecute, args)
|
||||||
.WorkingDirectory(workingDirectory)
|
.WorkingDirectory(workingDirectory)
|
||||||
.CaptureStdOut()
|
.CaptureStdOut()
|
||||||
.CaptureStdErr();
|
.CaptureStdErr();
|
||||||
|
@ -104,6 +114,7 @@ namespace Microsoft.DotNet.Configurer
|
||||||
if (commandResult.ExitCode != 0)
|
if (commandResult.ExitCode != 0)
|
||||||
{
|
{
|
||||||
Reporter.Verbose.WriteLine(commandResult.StdErr);
|
Reporter.Verbose.WriteLine(commandResult.StdErr);
|
||||||
|
|
||||||
Reporter.Error.WriteLine(
|
Reporter.Error.WriteLine(
|
||||||
$"Failed to create prime the NuGet cache. {commandToExecute} failed with: {commandResult.ExitCode}");
|
$"Failed to create prime the NuGet cache. {commandToExecute} failed with: {commandResult.ExitCode}");
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,13 @@ namespace Microsoft.DotNet.Cli
|
||||||
{
|
{
|
||||||
public class DotNetCommandFactory : ICommandFactory
|
public class DotNetCommandFactory : ICommandFactory
|
||||||
{
|
{
|
||||||
|
private bool _alwaysRunOutOfProc;
|
||||||
|
|
||||||
|
public DotNetCommandFactory(bool alwaysRunOutOfProc = false)
|
||||||
|
{
|
||||||
|
_alwaysRunOutOfProc = alwaysRunOutOfProc;
|
||||||
|
}
|
||||||
|
|
||||||
public ICommand Create(
|
public ICommand Create(
|
||||||
string commandName,
|
string commandName,
|
||||||
IEnumerable<string> args,
|
IEnumerable<string> args,
|
||||||
|
@ -18,7 +25,7 @@ namespace Microsoft.DotNet.Cli
|
||||||
string configuration = Constants.DefaultConfiguration)
|
string configuration = Constants.DefaultConfiguration)
|
||||||
{
|
{
|
||||||
Func<string[], int> builtInCommand;
|
Func<string[], int> builtInCommand;
|
||||||
if (Program.TryGetBuiltInCommand(commandName, out builtInCommand))
|
if (!_alwaysRunOutOfProc && Program.TryGetBuiltInCommand(commandName, out builtInCommand))
|
||||||
{
|
{
|
||||||
Debug.Assert(framework == null, "BuiltInCommand doesn't support the 'framework' argument.");
|
Debug.Assert(framework == null, "BuiltInCommand doesn't support the 'framework' argument.");
|
||||||
Debug.Assert(configuration == Constants.DefaultConfiguration, "BuiltInCommand doesn't support the 'configuration' argument.");
|
Debug.Assert(configuration == Constants.DefaultConfiguration, "BuiltInCommand doesn't support the 'configuration' argument.");
|
||||||
|
|
|
@ -198,7 +198,7 @@ namespace Microsoft.DotNet.Cli
|
||||||
using (var nugetPackagesArchiver = new NuGetPackagesArchiver())
|
using (var nugetPackagesArchiver = new NuGetPackagesArchiver())
|
||||||
{
|
{
|
||||||
var environmentProvider = new EnvironmentProvider();
|
var environmentProvider = new EnvironmentProvider();
|
||||||
var commandFactory = new DotNetCommandFactory();
|
var commandFactory = new DotNetCommandFactory(alwaysRunOutOfProc: true);
|
||||||
var nugetCachePrimer =
|
var nugetCachePrimer =
|
||||||
new NuGetCachePrimer(commandFactory, nugetPackagesArchiver, nugetCacheSentinel);
|
new NuGetCachePrimer(commandFactory, nugetPackagesArchiver, nugetCacheSentinel);
|
||||||
var dotnetConfigurer = new DotnetFirstTimeUseConfigurer(
|
var dotnetConfigurer = new DotnetFirstTimeUseConfigurer(
|
||||||
|
|
|
@ -57,7 +57,7 @@ namespace Microsoft.DotNet.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void It_shows_the_appropriate_message_to_the_user()
|
public void It_shows_the_appropriate_message_to_the_user()
|
||||||
{
|
{
|
||||||
const string firstTimeUseWelcomeMessage = @"Welcome to .NET Core!
|
string firstTimeUseWelcomeMessage = NormalizeLineEndings(@"Welcome to .NET Core!
|
||||||
---------------------
|
---------------------
|
||||||
Learn more about .NET Core @ https://aka.ms/dotnet-docs. Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs.
|
Learn more about .NET Core @ https://aka.ms/dotnet-docs. Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs.
|
||||||
Telemetry
|
Telemetry
|
||||||
|
@ -67,12 +67,12 @@ You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environmen
|
||||||
You can read more about .NET Core tools telemetry @ https://aka.ms/dotnet-cli-telemetry.
|
You can read more about .NET Core tools telemetry @ https://aka.ms/dotnet-cli-telemetry.
|
||||||
Configuring...
|
Configuring...
|
||||||
-------------------
|
-------------------
|
||||||
A command is running to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once.";
|
A command is running to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once.");
|
||||||
|
|
||||||
// normalizing line endings as git is occasionally replacing line endings in this file causing this test to fail
|
// normalizing line endings as git is occasionally replacing line endings in this file causing this test to fail
|
||||||
NormalizeLineEndings(_firstDotnetVerbUseCommandResult.StdOut)
|
NormalizeLineEndings(_firstDotnetVerbUseCommandResult.StdOut)
|
||||||
.Should()
|
.Should().StartWith(firstTimeUseWelcomeMessage)
|
||||||
.StartWith(NormalizeLineEndings(firstTimeUseWelcomeMessage));
|
.And.NotContain("Restore completed in");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
Loading…
Reference in a new issue