diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets index 07e579f5f38e..e1b1efd50367 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets @@ -134,6 +134,15 @@ Copyright (c) .NET Foundation. All rights reserved. + + + + + + + + + diff --git a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreAppForTelemetry.cs b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreAppForTelemetry.cs index b268f0d49b67..54bc27a974d3 100644 --- a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreAppForTelemetry.cs +++ b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreAppForTelemetry.cs @@ -11,6 +11,27 @@ public GivenThatWeWantToBuildANetCoreAppAndPassingALogger(ITestOutputHelper log) { } + private string CreateTargetFrameworkEvalTelemetryJson( + string targetFrameworkVersion, + string targetPlatformIdentifier = "null", + string runtimeIdentifier = "null", + string selfContained = "null", + string useApphost = "null", + string outputType = "Library", + string useArtifactsOutput = "null", + string artifactsPathLocationType = "null", + string useMonoRuntime = "null", + string publishAot = "null", + string publishTrimmed = "null", + string publishSelfContained = "null", + string publishReadyToRun = "null", + string publishReadyToRunComposite = "false", + string publishProtocol = "null", + string configuration = "Debug") + { + 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}\"}}"; + } + [CoreMSBuildOnlyFact] public void It_collects_TargetFramework_version_and_other_properties() { @@ -32,7 +53,8 @@ public void It_collects_TargetFramework_version_and_other_properties() buildCommand .Execute(TelemetryTestLogger) .StdOut.Should() - .Contain($"{{\"EventName\":\"targetframeworkeval\",\"Properties\":{{\"TargetFrameworkVersion\":\".NETCoreApp,Version=v{ToolsetInfo.CurrentTargetFrameworkVersion}\",\"RuntimeIdentifier\":\"null\",\"SelfContained\":\"null\",\"UseApphost\":\"null\",\"OutputType\":\"Library\",\"UseArtifactsOutput\":\"null\",\"ArtifactsPathLocationType\":\"null\"}}"); + .Contain(CreateTargetFrameworkEvalTelemetryJson( + $".NETCoreApp,Version=v{ToolsetInfo.CurrentTargetFrameworkVersion}")); } [CoreMSBuildOnlyFact] @@ -59,11 +81,13 @@ public void It_collects_multi_TargetFramework_version_and_other_properties() result .StdOut.Should() - .Contain( - "{\"EventName\":\"targetframeworkeval\",\"Properties\":{\"TargetFrameworkVersion\":\".NETFramework,Version=v4.6\",\"RuntimeIdentifier\":\"null\",\"SelfContained\":\"null\",\"UseApphost\":\"null\",\"OutputType\":\"Library\",\"UseArtifactsOutput\":\"null\",\"ArtifactsPathLocationType\":\"null\"}") + .Contain(CreateTargetFrameworkEvalTelemetryJson( + ".NETFramework,Version=v4.6", + targetPlatformIdentifier: "Windows", + publishReadyToRunComposite: "null")) .And - .Contain( - $"{{\"EventName\":\"targetframeworkeval\",\"Properties\":{{\"TargetFrameworkVersion\":\".NETCoreApp,Version=v{ToolsetInfo.CurrentTargetFrameworkVersion}\",\"RuntimeIdentifier\":\"null\",\"SelfContained\":\"null\",\"UseApphost\":\"null\",\"OutputType\":\"Library\",\"UseArtifactsOutput\":\"null\",\"ArtifactsPathLocationType\":\"null\"}}"); + .Contain(CreateTargetFrameworkEvalTelemetryJson( + $".NETCoreApp,Version=v{ToolsetInfo.CurrentTargetFrameworkVersion}")); } } }