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()
|
||||
{
|
||||
_stdErr.Capture();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public ICommand CaptureStdOut()
|
||||
{
|
||||
_stdOut.Capture();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -160,7 +160,7 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
#endif
|
||||
|
||||
return new CommandResult(
|
||||
this._process.StartInfo,
|
||||
_process.StartInfo,
|
||||
exitCode,
|
||||
_stdOut?.CapturedOutput,
|
||||
_stdErr?.CapturedOutput);
|
||||
|
|
|
@ -11,9 +11,13 @@ namespace Microsoft.DotNet.Configurer
|
|||
public class NuGetCachePrimer : INuGetCachePrimer
|
||||
{
|
||||
private readonly ICommandFactory _commandFactory;
|
||||
|
||||
private readonly IDirectory _directory;
|
||||
|
||||
private readonly IFile _file;
|
||||
|
||||
private readonly INuGetPackagesArchiver _nugetPackagesArchiver;
|
||||
|
||||
private readonly INuGetCacheSentinel _nuGetCacheSentinel;
|
||||
|
||||
public NuGetCachePrimer(
|
||||
|
@ -36,9 +40,13 @@ namespace Microsoft.DotNet.Configurer
|
|||
IFile file)
|
||||
{
|
||||
_commandFactory = commandFactory;
|
||||
|
||||
_directory = directory;
|
||||
|
||||
_nugetPackagesArchiver = nugetPackagesArchiver;
|
||||
|
||||
_nuGetCacheSentinel = nuGetCacheSentinel;
|
||||
|
||||
_file = file;
|
||||
}
|
||||
|
||||
|
@ -64,12 +72,14 @@ namespace Microsoft.DotNet.Configurer
|
|||
using (var temporaryDotnetNewDirectory = _directory.CreateTemporaryDirectory())
|
||||
{
|
||||
var workingDirectory = temporaryDotnetNewDirectory.DirectoryPath;
|
||||
|
||||
var createProjectSucceeded = CreateTemporaryProject(workingDirectory);
|
||||
|
||||
if (createProjectSucceeded)
|
||||
{
|
||||
var restoreProjectSucceeded =
|
||||
RestoreTemporaryProject(extractedPackagesArchiveDirectory, workingDirectory);
|
||||
|
||||
if (restoreProjectSucceeded)
|
||||
{
|
||||
_nuGetCacheSentinel.CreateIfNotExists();
|
||||
|
@ -93,8 +103,8 @@ namespace Microsoft.DotNet.Configurer
|
|||
|
||||
private bool RunCommand(string commandToExecute, IEnumerable<string> args, string workingDirectory)
|
||||
{
|
||||
var command = _commandFactory
|
||||
.Create(commandToExecute, args)
|
||||
var command = _commandFactory
|
||||
.Create(commandToExecute, args)
|
||||
.WorkingDirectory(workingDirectory)
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr();
|
||||
|
@ -104,6 +114,7 @@ namespace Microsoft.DotNet.Configurer
|
|||
if (commandResult.ExitCode != 0)
|
||||
{
|
||||
Reporter.Verbose.WriteLine(commandResult.StdErr);
|
||||
|
||||
Reporter.Error.WriteLine(
|
||||
$"Failed to create prime the NuGet cache. {commandToExecute} failed with: {commandResult.ExitCode}");
|
||||
}
|
||||
|
|
|
@ -11,6 +11,13 @@ namespace Microsoft.DotNet.Cli
|
|||
{
|
||||
public class DotNetCommandFactory : ICommandFactory
|
||||
{
|
||||
private bool _alwaysRunOutOfProc;
|
||||
|
||||
public DotNetCommandFactory(bool alwaysRunOutOfProc = false)
|
||||
{
|
||||
_alwaysRunOutOfProc = alwaysRunOutOfProc;
|
||||
}
|
||||
|
||||
public ICommand Create(
|
||||
string commandName,
|
||||
IEnumerable<string> args,
|
||||
|
@ -18,7 +25,7 @@ namespace Microsoft.DotNet.Cli
|
|||
string configuration = Constants.DefaultConfiguration)
|
||||
{
|
||||
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(configuration == Constants.DefaultConfiguration, "BuiltInCommand doesn't support the 'configuration' argument.");
|
||||
|
|
|
@ -198,7 +198,7 @@ namespace Microsoft.DotNet.Cli
|
|||
using (var nugetPackagesArchiver = new NuGetPackagesArchiver())
|
||||
{
|
||||
var environmentProvider = new EnvironmentProvider();
|
||||
var commandFactory = new DotNetCommandFactory();
|
||||
var commandFactory = new DotNetCommandFactory(alwaysRunOutOfProc: true);
|
||||
var nugetCachePrimer =
|
||||
new NuGetCachePrimer(commandFactory, nugetPackagesArchiver, nugetCacheSentinel);
|
||||
var dotnetConfigurer = new DotnetFirstTimeUseConfigurer(
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace Microsoft.DotNet.Tests
|
|||
[Fact]
|
||||
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.
|
||||
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.
|
||||
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
|
||||
NormalizeLineEndings(_firstDotnetVerbUseCommandResult.StdOut)
|
||||
.Should()
|
||||
.StartWith(NormalizeLineEndings(firstTimeUseWelcomeMessage));
|
||||
.Should().StartWith(firstTimeUseWelcomeMessage)
|
||||
.And.NotContain("Restore completed in");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
Loading…
Reference in a new issue