2016-06-03 17:36:40 -07:00
|
|
|
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
|
|
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
using Microsoft.DotNet.Cli.Utils;
|
|
|
|
|
using Microsoft.Extensions.EnvironmentAbstractions;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Configurer
|
|
|
|
|
{
|
|
|
|
|
public class DotnetFirstTimeUseConfigurer
|
|
|
|
|
{
|
|
|
|
|
private INuGetCachePrimer _nugetCachePrimer;
|
2016-06-06 10:39:05 -07:00
|
|
|
|
private INuGetCacheSentinel _nugetCacheSentinel;
|
2016-06-03 17:36:40 -07:00
|
|
|
|
|
2016-06-06 10:39:05 -07:00
|
|
|
|
public DotnetFirstTimeUseConfigurer(INuGetCachePrimer nugetCachePrimer, INuGetCacheSentinel nugetCacheSentinel)
|
2016-06-03 17:36:40 -07:00
|
|
|
|
{
|
|
|
|
|
_nugetCachePrimer = nugetCachePrimer;
|
2016-06-06 10:39:05 -07:00
|
|
|
|
_nugetCacheSentinel = nugetCacheSentinel;
|
2016-06-03 17:36:40 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Configure()
|
|
|
|
|
{
|
|
|
|
|
if(ShouldPrimeNugetCache())
|
|
|
|
|
{
|
2016-06-09 20:52:49 -07:00
|
|
|
|
PrintFirstTimeUseNotice();
|
|
|
|
|
|
2016-06-03 17:36:40 -07:00
|
|
|
|
_nugetCachePrimer.PrimeCache();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-09 20:52:49 -07:00
|
|
|
|
private void PrintFirstTimeUseNotice()
|
|
|
|
|
{
|
|
|
|
|
Reporter.Output.WriteLine();
|
|
|
|
|
Reporter.Output.WriteLine("Welcome to .NET Core!");
|
|
|
|
|
Reporter.Output.WriteLine("---------------------");
|
|
|
|
|
Reporter.Output.WriteLine("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.");
|
|
|
|
|
Reporter.Output.WriteLine("Telemetry");
|
|
|
|
|
Reporter.Output.WriteLine("--------------");
|
|
|
|
|
Reporter.Output.WriteLine("The .NET Core tools collect usage data in order to improve your experience. " +
|
|
|
|
|
"The data is anonymous and does not include commandline arguments. " +
|
|
|
|
|
"The data is collected by Microsoft and shared with the community.");
|
|
|
|
|
Reporter.Output.WriteLine();
|
|
|
|
|
Reporter.Output.WriteLine("You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT " +
|
|
|
|
|
"environment variable to 1 using your favorite shell.");
|
|
|
|
|
Reporter.Output.WriteLine("You can read more about .NET Core tools telemetry @ https://aka.ms/dotnet-cli-telemetry.");
|
|
|
|
|
Reporter.Output.WriteLine("Configuring...");
|
|
|
|
|
Reporter.Output.WriteLine("-------------------");
|
|
|
|
|
Reporter.Output.WriteLine("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.");
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-03 17:36:40 -07:00
|
|
|
|
private bool ShouldPrimeNugetCache()
|
|
|
|
|
{
|
2016-06-06 10:39:05 -07:00
|
|
|
|
return !_nugetCacheSentinel.Exists();
|
2016-06-03 17:36:40 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|