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
|
|
|
|
|
{
|
2016-06-10 13:02:48 -07:00
|
|
|
|
private IEnvironmentProvider _environmentProvider;
|
2016-06-03 17:36:40 -07:00
|
|
|
|
private INuGetCachePrimer _nugetCachePrimer;
|
2016-06-06 10:39:05 -07:00
|
|
|
|
private INuGetCacheSentinel _nugetCacheSentinel;
|
2016-06-03 17:36:40 -07:00
|
|
|
|
|
2016-06-10 13:02:48 -07:00
|
|
|
|
public DotnetFirstTimeUseConfigurer(
|
|
|
|
|
INuGetCachePrimer nugetCachePrimer,
|
|
|
|
|
INuGetCacheSentinel nugetCacheSentinel,
|
|
|
|
|
IEnvironmentProvider environmentProvider)
|
2016-06-03 17:36:40 -07:00
|
|
|
|
{
|
|
|
|
|
_nugetCachePrimer = nugetCachePrimer;
|
2016-06-06 10:39:05 -07:00
|
|
|
|
_nugetCacheSentinel = nugetCacheSentinel;
|
2016-06-10 13:02:48 -07:00
|
|
|
|
_environmentProvider = environmentProvider;
|
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()
|
|
|
|
|
{
|
2016-06-10 13:02:48 -07:00
|
|
|
|
const string firstTimeUseWelcomeMessage = @"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.
|
2016-07-21 23:00:26 -07:00
|
|
|
|
|
2016-06-10 13:02:48 -07:00
|
|
|
|
Telemetry
|
|
|
|
|
--------------
|
2016-12-13 21:15:22 -06:00
|
|
|
|
The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include command-line arguments. The data is collected by Microsoft and shared with the community.
|
2016-06-10 13:02:48 -07:00
|
|
|
|
You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell.
|
|
|
|
|
You can read more about .NET Core tools telemetry @ https://aka.ms/dotnet-cli-telemetry.
|
2016-07-21 23:00:26 -07:00
|
|
|
|
|
2016-06-10 13:02:48 -07:00
|
|
|
|
Configuring...
|
|
|
|
|
-------------------
|
2016-06-10 15:06:48 -07:00
|
|
|
|
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-10 13:02:48 -07:00
|
|
|
|
|
2016-06-09 20:52:49 -07:00
|
|
|
|
Reporter.Output.WriteLine();
|
2016-06-10 13:02:48 -07:00
|
|
|
|
Reporter.Output.WriteLine(firstTimeUseWelcomeMessage);
|
2016-06-09 20:52:49 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-06-03 17:36:40 -07:00
|
|
|
|
private bool ShouldPrimeNugetCache()
|
|
|
|
|
{
|
2016-06-10 13:02:48 -07:00
|
|
|
|
var skipFirstTimeExperience =
|
2016-06-10 15:06:48 -07:00
|
|
|
|
_environmentProvider.GetEnvironmentVariableAsBool("DOTNET_SKIP_FIRST_TIME_EXPERIENCE", false);
|
2016-06-10 13:02:48 -07:00
|
|
|
|
|
2016-06-10 15:06:48 -07:00
|
|
|
|
return !skipFirstTimeExperience &&
|
|
|
|
|
!_nugetCacheSentinel.Exists() &&
|
|
|
|
|
!_nugetCacheSentinel.InProgressSentinelAlreadyExists();
|
2016-06-03 17:36:40 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|