Set DOTNET_CLI_TELEMETRY_PROFILE for CLI Repo builds (#3228)

This commit is contained in:
Piotr Puszkiewicz 2016-05-25 09:21:08 -07:00
parent 8422fcb9b0
commit 8ffba3c029

View file

@ -38,7 +38,8 @@ namespace Microsoft.DotNet.Cli.Build
nameof(UpdateTemplateVersions), nameof(UpdateTemplateVersions),
nameof(CheckPrereqs), nameof(CheckPrereqs),
nameof(LocateStage0), nameof(LocateStage0),
nameof(ExpectedBuildArtifacts))] nameof(ExpectedBuildArtifacts),
nameof(SetTelemetryProfile))]
public static BuildTargetResult Init(BuildTargetContext c) public static BuildTargetResult Init(BuildTargetContext c)
{ {
var configEnv = Environment.GetEnvironmentVariable("CONFIGURATION"); var configEnv = Environment.GetEnvironmentVariable("CONFIGURATION");
@ -359,6 +360,21 @@ cmake is required to build the native host 'corehost'";
return c.Success(); return c.Success();
} }
[Target]
public static BuildTargetResult SetTelemetryProfile(BuildTargetContext c)
{
var gitResult = Cmd("git", "rev-parse", "HEAD")
.CaptureStdOut()
.Execute();
gitResult.EnsureSuccessful();
var commitHash = gitResult.StdOut.Trim();
Environment.SetEnvironmentVariable("DOTNET_CLI_TELEMETRY_PROFILE", $"https://github.com/dotnet/cli;{commitHash}");
return c.Success();
}
private static string GetVersionFromProjectJson(string pathToProjectJson) private static string GetVersionFromProjectJson(string pathToProjectJson)
{ {
Regex r = new Regex($"\"{Regex.Escape(Monikers.SharedFrameworkName)}\"\\s*:\\s*\"(?'version'[^\"]*)\""); Regex r = new Regex($"\"{Regex.Escape(Monikers.SharedFrameworkName)}\"\\s*:\\s*\"(?'version'[^\"]*)\"");