Skip to content

Commit 7b1b205

Browse files
github-actions[bot]matouskozakbaronfel
authored
[release/10.0.1xx] Add more properties to targetframeworkeval telemetry event (#50782)
Co-authored-by: Matous Kozak <[email protected]> Co-authored-by: Matous Kozak <[email protected]> Co-authored-by: Chet Husk <[email protected]>
1 parent 2d51781 commit 7b1b205

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,15 @@ Copyright (c) .NET Foundation. All rights reserved.
134134
<TFTelemetry Include="OutputType" Value="$(OutputType)" />
135135
<TFTelemetry Include="UseArtifactsOutput" Value="$(UseArtifactsOutput)" />
136136
<TFTelemetry Include="ArtifactsPathLocationType" Value="$(_ArtifactsPathLocationType)" />
137+
<TFTelemetry Include="TargetPlatformIdentifier" Value="$(TargetPlatformIdentifier)" />
138+
<TFTelemetry Include="UseMonoRuntime" Value="$(UseMonoRuntime)" />
139+
<TFTelemetry Include="PublishAot" Value="$(PublishAot)" />
140+
<TFTelemetry Include="PublishTrimmed" Value="$(PublishTrimmed)" />
141+
<TFTelemetry Include="PublishSelfContained" Value="$(PublishSelfContained)" />
142+
<TFTelemetry Include="PublishReadyToRun" Value="$(PublishReadyToRun)" />
143+
<TFTelemetry Include="PublishReadyToRunComposite" Value="$(PublishReadyToRunComposite)" />
144+
<TFTelemetry Include="PublishProtocol" Value="$(PublishProtocol)" />
145+
<TFTelemetry Include="Configuration" Value="$(Configuration)" />
137146
</ItemGroup>
138147
<AllowEmptyTelemetry EventName="targetframeworkeval" EventData="@(TFTelemetry)" />
139148
</Target>

test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreAppForTelemetry.cs

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,27 @@ public GivenThatWeWantToBuildANetCoreAppAndPassingALogger(ITestOutputHelper log)
1111
{
1212
}
1313

14+
private string CreateTargetFrameworkEvalTelemetryJson(
15+
string targetFrameworkVersion,
16+
string targetPlatformIdentifier = "null",
17+
string runtimeIdentifier = "null",
18+
string selfContained = "null",
19+
string useApphost = "null",
20+
string outputType = "Library",
21+
string useArtifactsOutput = "null",
22+
string artifactsPathLocationType = "null",
23+
string useMonoRuntime = "null",
24+
string publishAot = "null",
25+
string publishTrimmed = "null",
26+
string publishSelfContained = "null",
27+
string publishReadyToRun = "null",
28+
string publishReadyToRunComposite = "false",
29+
string publishProtocol = "null",
30+
string configuration = "Debug")
31+
{
32+
return $"{{\"EventName\":\"targetframeworkeval\",\"Properties\":{{\"TargetFrameworkVersion\":\"{targetFrameworkVersion}\",\"RuntimeIdentifier\":\"{runtimeIdentifier}\",\"SelfContained\":\"{selfContained}\",\"UseApphost\":\"{useApphost}\",\"OutputType\":\"{outputType}\",\"UseArtifactsOutput\":\"{useArtifactsOutput}\",\"ArtifactsPathLocationType\":\"{artifactsPathLocationType}\",\"TargetPlatformIdentifier\":\"{targetPlatformIdentifier}\",\"UseMonoRuntime\":\"{useMonoRuntime}\",\"PublishAot\":\"{publishAot}\",\"PublishTrimmed\":\"{publishTrimmed}\",\"PublishSelfContained\":\"{publishSelfContained}\",\"PublishReadyToRun\":\"{publishReadyToRun}\",\"PublishReadyToRunComposite\":\"{publishReadyToRunComposite}\",\"PublishProtocol\":\"{publishProtocol}\",\"Configuration\":\"{configuration}\"}}";
33+
}
34+
1435
[CoreMSBuildOnlyFact]
1536
public void It_collects_TargetFramework_version_and_other_properties()
1637
{
@@ -32,7 +53,8 @@ public void It_collects_TargetFramework_version_and_other_properties()
3253
buildCommand
3354
.Execute(TelemetryTestLogger)
3455
.StdOut.Should()
35-
.Contain($"{{\"EventName\":\"targetframeworkeval\",\"Properties\":{{\"TargetFrameworkVersion\":\".NETCoreApp,Version=v{ToolsetInfo.CurrentTargetFrameworkVersion}\",\"RuntimeIdentifier\":\"null\",\"SelfContained\":\"null\",\"UseApphost\":\"null\",\"OutputType\":\"Library\",\"UseArtifactsOutput\":\"null\",\"ArtifactsPathLocationType\":\"null\"}}");
56+
.Contain(CreateTargetFrameworkEvalTelemetryJson(
57+
$".NETCoreApp,Version=v{ToolsetInfo.CurrentTargetFrameworkVersion}"));
3658
}
3759

3860
[CoreMSBuildOnlyFact]
@@ -59,11 +81,13 @@ public void It_collects_multi_TargetFramework_version_and_other_properties()
5981

6082
result
6183
.StdOut.Should()
62-
.Contain(
63-
"{\"EventName\":\"targetframeworkeval\",\"Properties\":{\"TargetFrameworkVersion\":\".NETFramework,Version=v4.6\",\"RuntimeIdentifier\":\"null\",\"SelfContained\":\"null\",\"UseApphost\":\"null\",\"OutputType\":\"Library\",\"UseArtifactsOutput\":\"null\",\"ArtifactsPathLocationType\":\"null\"}")
84+
.Contain(CreateTargetFrameworkEvalTelemetryJson(
85+
".NETFramework,Version=v4.6",
86+
targetPlatformIdentifier: "Windows",
87+
publishReadyToRunComposite: "null"))
6488
.And
65-
.Contain(
66-
$"{{\"EventName\":\"targetframeworkeval\",\"Properties\":{{\"TargetFrameworkVersion\":\".NETCoreApp,Version=v{ToolsetInfo.CurrentTargetFrameworkVersion}\",\"RuntimeIdentifier\":\"null\",\"SelfContained\":\"null\",\"UseApphost\":\"null\",\"OutputType\":\"Library\",\"UseArtifactsOutput\":\"null\",\"ArtifactsPathLocationType\":\"null\"}}");
89+
.Contain(CreateTargetFrameworkEvalTelemetryJson(
90+
$".NETCoreApp,Version=v{ToolsetInfo.CurrentTargetFrameworkVersion}"));
6791
}
6892
}
6993
}

0 commit comments

Comments
 (0)