Remove showing firsttime eula for non verbs.
This commit is contained in:
parent
0589496b98
commit
eab2494ed5
3 changed files with 35 additions and 10 deletions
|
@ -55,11 +55,9 @@ namespace Microsoft.DotNet.Cli
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ConfigureDotNetForFirstTimeUse();
|
|
||||||
|
|
||||||
using (PerfTrace.Current.CaptureTiming())
|
using (PerfTrace.Current.CaptureTiming())
|
||||||
{
|
{
|
||||||
return ProcessArgs(args, new Telemetry());
|
return ProcessArgs(args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (GracefulException e)
|
catch (GracefulException e)
|
||||||
|
@ -78,7 +76,7 @@ namespace Microsoft.DotNet.Cli
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static int ProcessArgs(string[] args, ITelemetry telemetryClient)
|
internal static int ProcessArgs(string[] args, ITelemetry telemetryClient = null)
|
||||||
{
|
{
|
||||||
// CommandLineApplication is a bit restrictive, so we parse things ourselves here. Individual apps should use CLA.
|
// CommandLineApplication is a bit restrictive, so we parse things ourselves here. Individual apps should use CLA.
|
||||||
|
|
||||||
|
@ -86,6 +84,7 @@ namespace Microsoft.DotNet.Cli
|
||||||
var success = true;
|
var success = true;
|
||||||
var command = string.Empty;
|
var command = string.Empty;
|
||||||
var lastArg = 0;
|
var lastArg = 0;
|
||||||
|
|
||||||
for (; lastArg < args.Length; lastArg++)
|
for (; lastArg < args.Length; lastArg++)
|
||||||
{
|
{
|
||||||
if (IsArg(args[lastArg], "v", "verbose"))
|
if (IsArg(args[lastArg], "v", "verbose"))
|
||||||
|
@ -114,6 +113,8 @@ namespace Microsoft.DotNet.Cli
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
ConfigureDotNetForFirstTimeUse();
|
||||||
|
|
||||||
// It's the command, and we're done!
|
// It's the command, and we're done!
|
||||||
command = args[lastArg];
|
command = args[lastArg];
|
||||||
break;
|
break;
|
||||||
|
@ -125,6 +126,9 @@ namespace Microsoft.DotNet.Cli
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (telemetryClient == null)
|
||||||
|
telemetryClient = new Telemetry();
|
||||||
|
|
||||||
var appArgs = (lastArg + 1) >= args.Length ? Enumerable.Empty<string>() : args.Skip(lastArg + 1).ToArray();
|
var appArgs = (lastArg + 1) >= args.Length ? Enumerable.Empty<string>() : args.Skip(lastArg + 1).ToArray();
|
||||||
|
|
||||||
if (verbose.HasValue)
|
if (verbose.HasValue)
|
||||||
|
@ -178,6 +182,9 @@ namespace Microsoft.DotNet.Cli
|
||||||
environmentProvider);
|
environmentProvider);
|
||||||
|
|
||||||
dotnetConfigurer.Configure();
|
dotnetConfigurer.Configure();
|
||||||
|
|
||||||
|
if (!File.Exists(Telemetry.TelemetrySentinel))
|
||||||
|
File.Create(Telemetry.TelemetrySentinel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.ApplicationInsights;
|
using Microsoft.ApplicationInsights;
|
||||||
using Microsoft.DotNet.Cli.Utils;
|
using Microsoft.DotNet.Cli.Utils;
|
||||||
|
@ -19,6 +20,8 @@ namespace Microsoft.DotNet.Cli
|
||||||
private Dictionary<string, double> _commonMeasurements = null;
|
private Dictionary<string, double> _commonMeasurements = null;
|
||||||
private Task _trackEventTask = null;
|
private Task _trackEventTask = null;
|
||||||
|
|
||||||
|
internal static readonly string TelemetrySentinel = Path.Combine(ApplicationEnvironment.ApplicationBasePath, $"{Product.Version}.dotnetTelemetry");
|
||||||
|
|
||||||
private const string InstrumentationKey = "74cc1c9e-3e6e-4d05-b3fc-dde9101d0254";
|
private const string InstrumentationKey = "74cc1c9e-3e6e-4d05-b3fc-dde9101d0254";
|
||||||
private const string TelemetryOptout = "DOTNET_CLI_TELEMETRY_OPTOUT";
|
private const string TelemetryOptout = "DOTNET_CLI_TELEMETRY_OPTOUT";
|
||||||
private const string TelemetryProfileEnvironmentVariable = "DOTNET_CLI_TELEMETRY_PROFILE";
|
private const string TelemetryProfileEnvironmentVariable = "DOTNET_CLI_TELEMETRY_PROFILE";
|
||||||
|
@ -32,7 +35,7 @@ namespace Microsoft.DotNet.Cli
|
||||||
|
|
||||||
public Telemetry()
|
public Telemetry()
|
||||||
{
|
{
|
||||||
Enabled = !Env.GetEnvironmentVariableAsBool(TelemetryOptout);
|
Enabled = !Env.GetEnvironmentVariableAsBool(TelemetryOptout) && PermissionExists();
|
||||||
|
|
||||||
if (!Enabled)
|
if (!Enabled)
|
||||||
{
|
{
|
||||||
|
@ -42,6 +45,11 @@ namespace Microsoft.DotNet.Cli
|
||||||
//initialize in task to offload to parallel thread
|
//initialize in task to offload to parallel thread
|
||||||
_trackEventTask = Task.Factory.StartNew(() => InitializeTelemetry());
|
_trackEventTask = Task.Factory.StartNew(() => InitializeTelemetry());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool PermissionExists()
|
||||||
|
{
|
||||||
|
return File.Exists(TelemetrySentinel);
|
||||||
|
}
|
||||||
|
|
||||||
public void TrackEvent(string eventName, IDictionary<string, string> properties, IDictionary<string, double> measurements)
|
public void TrackEvent(string eventName, IDictionary<string, string> properties, IDictionary<string, double> measurements)
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,7 +15,8 @@ namespace Microsoft.DotNet.Tests
|
||||||
{
|
{
|
||||||
public class GivenThatTheUserIsRunningDotNetForTheFirstTime : TestBase
|
public class GivenThatTheUserIsRunningDotNetForTheFirstTime : TestBase
|
||||||
{
|
{
|
||||||
private static CommandResult _firstDotnetUseCommandResult;
|
private static CommandResult _firstDotnetInfoUseCommandResult;
|
||||||
|
private static CommandResult _firstDotnetNewUseCommandResult;
|
||||||
private static DirectoryInfo _nugetCacheFolder;
|
private static DirectoryInfo _nugetCacheFolder;
|
||||||
|
|
||||||
static GivenThatTheUserIsRunningDotNetForTheFirstTime()
|
static GivenThatTheUserIsRunningDotNetForTheFirstTime()
|
||||||
|
@ -28,7 +29,8 @@ namespace Microsoft.DotNet.Tests
|
||||||
command.Environment["NUGET_PACKAGES"] = testNugetCache;
|
command.Environment["NUGET_PACKAGES"] = testNugetCache;
|
||||||
command.Environment["DOTNET_SKIP_FIRST_TIME_EXPERIENCE"] = "";
|
command.Environment["DOTNET_SKIP_FIRST_TIME_EXPERIENCE"] = "";
|
||||||
|
|
||||||
_firstDotnetUseCommandResult = command.ExecuteWithCapturedOutput("new");
|
_firstDotnetInfoUseCommandResult = command.ExecuteWithCapturedOutput("--info");
|
||||||
|
_firstDotnetNewUseCommandResult = command.ExecuteWithCapturedOutput("new");
|
||||||
|
|
||||||
_nugetCacheFolder = new DirectoryInfo(testNugetCache);
|
_nugetCacheFolder = new DirectoryInfo(testNugetCache);
|
||||||
}
|
}
|
||||||
|
@ -36,7 +38,15 @@ namespace Microsoft.DotNet.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Using_dotnet_for_the_first_time_succeeds()
|
public void Using_dotnet_for_the_first_time_succeeds()
|
||||||
{
|
{
|
||||||
_firstDotnetUseCommandResult.Should().Pass();
|
_firstDotnetNewUseCommandResult.Should().Pass();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Using_dotnet_for_the_first_time_with_non_verbs_doesnt_print_eula()
|
||||||
|
{
|
||||||
|
const string firstTimeUseWelcomeMessage = @".NET Command Line Tools";
|
||||||
|
|
||||||
|
_firstDotnetInfoUseCommandResult.StdOut.Should().StartWith(firstTimeUseWelcomeMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
@ -54,12 +64,12 @@ 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.";
|
||||||
|
|
||||||
_firstDotnetUseCommandResult.StdOut.Should().StartWith(firstTimeUseWelcomeMessage);
|
_firstDotnetNewUseCommandResult.StdOut.Should().StartWith(firstTimeUseWelcomeMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void It_restores_the_nuget_packages_to_the_nuget_cache_folder()
|
public void It_restores_the_nuget_packages_to_the_nuget_cache_folder()
|
||||||
{
|
{
|
||||||
_nugetCacheFolder.Should().HaveFile($"{GetDotnetVersion()}.dotnetSentinel");
|
_nugetCacheFolder.Should().HaveFile($"{GetDotnetVersion()}.dotnetSentinel");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue