@@ -3082,6 +3082,7 @@ await SimpleTestPackageUtility.CreateFolderFeedV3Async(
30823082 [ "Audit.Duration.Total" ] = value => value . Should ( ) . BeOfType < double > ( ) ,
30833083 [ "UseLegacyDependencyResolver" ] = value => value . Should ( ) . BeOfType < bool > ( ) ,
30843084 [ "UsedLegacyDependencyResolver" ] = value => value . Should ( ) . BeOfType < bool > ( ) ,
3085+ [ "TargetFrameworks" ] = value => value . Should ( ) . Be ( "net472" ) ,
30853086 [ "TargetFrameworksCount" ] = value => value . Should ( ) . Be ( 1 ) ,
30863087 [ "RuntimeIdentifiersCount" ] = value => value . Should ( ) . Be ( 0 ) ,
30873088 [ "TreatWarningsAsErrors" ] = value => value . Should ( ) . Be ( false ) ,
@@ -3155,6 +3156,50 @@ await SimpleTestPackageUtility.CreateFolderFeedV3Async(
31553156 Assert . Null ( projectInformationEvent [ "WarningCodes" ] ) ;
31563157 }
31573158
3159+ [ Fact ]
3160+ public async Task ExecuteAsync_WithMultiTargetedProject_PopulatesShortTargetFrameworkNamesTelemetry ( )
3161+ {
3162+ // Arrange
3163+ using var pathContext = new SimpleTestPathContext ( ) ;
3164+ var projectName = "TestProject" ;
3165+ var projectPath = Path . Combine ( pathContext . SolutionRoot , projectName ) ;
3166+ PackageSpec packageSpec = ProjectTestHelpers . GetPackageSpec ( projectName , pathContext . SolutionRoot , "net472" , "a" ) ;
3167+ NuGetFramework secondFramework = NuGetFramework . Parse ( ".NETCoreApp,Version=v8.0" ) ;
3168+ packageSpec . TargetFrameworks . Add ( new TargetFrameworkInformation ( ) { FrameworkName = secondFramework } ) ;
3169+ packageSpec . RestoreMetadata . TargetFrameworks . Add ( new ProjectRestoreMetadataFrameworkInfo ( secondFramework ) { TargetAlias = secondFramework . GetShortFolderName ( ) } ) ;
3170+ packageSpec . RestoreMetadata . OriginalTargetFrameworks . Add ( secondFramework . GetShortFolderName ( ) ) ;
3171+
3172+ await SimpleTestPackageUtility . CreateFolderFeedV3Async (
3173+ pathContext . PackageSource ,
3174+ PackageSaveMode . Defaultv3 ,
3175+ new SimpleTestPackageContext ( "a" , "1.0.0" ) ) ;
3176+
3177+ var logger = new TestLogger ( ) ;
3178+ var request = new TestRestoreRequest ( packageSpec , new PackageSource [ ] { new PackageSource ( pathContext . PackageSource ) } , pathContext . UserPackagesFolder , logger )
3179+ {
3180+ LockFilePath = Path . Combine ( projectPath , "project.assets.json" ) ,
3181+ ProjectStyle = ProjectStyle . PackageReference ,
3182+ } ;
3183+
3184+ var telemetryEvents = new ConcurrentQueue < TelemetryEvent > ( ) ;
3185+ var telemetryService = new Mock < INuGetTelemetryService > ( MockBehavior . Loose ) ;
3186+ telemetryService
3187+ . Setup ( x => x . EmitTelemetryEvent ( It . IsAny < TelemetryEvent > ( ) ) )
3188+ . Callback < TelemetryEvent > ( x => telemetryEvents . Enqueue ( x ) ) ;
3189+
3190+ TelemetryActivity . NuGetTelemetryService = telemetryService . Object ;
3191+
3192+ // Act
3193+ var restoreCommand = new RestoreCommand ( request ) ;
3194+ RestoreResult result = await restoreCommand . ExecuteAsync ( ) ;
3195+
3196+ // Assert
3197+ result . Success . Should ( ) . BeTrue ( because : logger . ShowMessages ( ) ) ;
3198+ var projectInformationEvent = telemetryEvents . Single ( e => e . Name . Equals ( "ProjectRestoreInformation" ) ) ;
3199+ projectInformationEvent [ "TargetFrameworks" ] . Should ( ) . Be ( "net472;net8.0" ) ;
3200+ projectInformationEvent [ "TargetFrameworksCount" ] . Should ( ) . Be ( 2 ) ;
3201+ }
3202+
31583203 [ Fact ]
31593204 public async Task ExecuteAsync_WithSinglePackage_WhenNoOping_PopulatesCorrectTelemetry ( )
31603205 {
@@ -3212,7 +3257,7 @@ await SimpleTestPackageUtility.CreateFolderFeedV3Async(
32123257
32133258 var projectInformationEvent = telemetryEvents . Single ( e => e . Name . Equals ( "ProjectRestoreInformation" ) ) ;
32143259
3215- projectInformationEvent . Count . Should ( ) . Be ( 41 ) ;
3260+ projectInformationEvent . Count . Should ( ) . Be ( 42 ) ;
32163261
32173262 projectInformationEvent [ "RestoreSuccess" ] . Should ( ) . Be ( true ) ;
32183263 projectInformationEvent [ "NoOpResult" ] . Should ( ) . Be ( true ) ;
@@ -3239,6 +3284,7 @@ await SimpleTestPackageUtility.CreateFolderFeedV3Async(
32393284 projectInformationEvent [ "UseLegacyDependencyResolver" ] . Should ( ) . BeOfType < bool > ( ) ;
32403285 projectInformationEvent [ "UsedLegacyDependencyResolver" ] . Should ( ) . BeOfType < bool > ( ) ;
32413286 projectInformationEvent [ "Audit.Enabled" ] . Should ( ) . BeOfType < string > ( ) ;
3287+ projectInformationEvent [ "TargetFrameworks" ] . Should ( ) . Be ( "net472" ) ;
32423288 projectInformationEvent [ "TargetFrameworksCount" ] . Should ( ) . Be ( 1 ) ;
32433289 projectInformationEvent [ "RuntimeIdentifiersCount" ] . Should ( ) . Be ( 0 ) ;
32443290 projectInformationEvent [ "TreatWarningsAsErrors" ] . Should ( ) . Be ( true ) ;
@@ -3312,11 +3358,12 @@ await SimpleTestPackageUtility.CreateFolderFeedV3Async(
33123358
33133359 var projectInformationEvent = telemetryEvents . Single ( e => e . Name . Equals ( "ProjectRestoreInformation" ) ) ;
33143360
3315- projectInformationEvent . Count . Should ( ) . Be ( 49 ) ;
3361+ projectInformationEvent . Count . Should ( ) . Be ( 50 ) ;
33163362 projectInformationEvent [ "RestoreSuccess" ] . Should ( ) . Be ( true ) ;
33173363 projectInformationEvent [ "NoOpResult" ] . Should ( ) . Be ( false ) ;
33183364 projectInformationEvent [ "TotalUniquePackagesCount" ] . Should ( ) . Be ( 2 ) ;
33193365 projectInformationEvent [ "NewPackagesInstalledCount" ] . Should ( ) . Be ( 1 ) ;
3366+ projectInformationEvent [ "TargetFrameworks" ] . Should ( ) . Be ( "net472" ) ;
33203367 projectInformationEvent [ "PackageSourceMapping.IsMappingEnabled" ] . Should ( ) . Be ( false ) ;
33213368 projectInformationEvent [ "UpdatedAssetsFile" ] . Should ( ) . Be ( true ) ;
33223369 projectInformationEvent [ "UpdatedMSBuildFiles" ] . Should ( ) . Be ( true ) ;
0 commit comments