@@ -329,8 +329,8 @@ public void PlatformPackagesCanBePruned(bool prunePackages)
329329 [ InlineData ( "netstandard1.1" , false ) ]
330330 [ InlineData ( "netstandard1.0" , false ) ]
331331 [ InlineData ( "net451" , false ) ]
332- [ InlineData ( "net462" ) ]
333- [ InlineData ( "net481" ) ]
332+ [ InlineData ( "net462" , false ) ]
333+ [ InlineData ( "net481" , false ) ]
334334 // These target frameworks shouldn't prune packages unless explicitly enabled
335335 [ InlineData ( "net9.0" , false , "" ) ]
336336 [ InlineData ( "netstandard2.1" , false , "" ) ]
@@ -492,6 +492,45 @@ public void WithMultitargetedProjects_PruningsDefaultsAreApplies(string framewor
492492 }
493493 }
494494
495+ [ Fact ]
496+ public void WithMultitargetedProject_NETFrameworkIsNotPruned ( )
497+ {
498+ var project = new TestProject ( "MultitargetedPruning" )
499+ {
500+ TargetFrameworks = ToolsetInfo . CurrentTargetFramework + ";net462" ,
501+ } ;
502+ project . PackageReferences . Add ( new TestPackageReference ( "System.ValueTuple" , "4.6.1" ) ) ;
503+ project . SourceFiles . Add ( "Test.cs" , @"
504+ public class Class1
505+ {
506+ public (int, int) GetTuple() => (1, 2);
507+ }
508+ " ) ;
509+ var testAsset = _testAssetsManager . CreateTestProject ( project , identifier : "NETFrameworkIsNotPruned" ) ;
510+ var buildCommand = new BuildCommand ( testAsset ) ;
511+ buildCommand . Execute ( ) . Should ( ) . Pass ( ) ;
512+ var assetsFilePath = Path . Combine ( buildCommand . GetBaseIntermediateDirectory ( ) . FullName , "project.assets.json" ) ;
513+ var lockFile = LockFileUtilities . GetLockFile ( assetsFilePath , new NullLogger ( ) ) ;
514+
515+ foreach ( var lockFileTarget in lockFile . Targets )
516+ {
517+ var valueTupleLibrary = lockFileTarget . Libraries . Where ( library => library . Name . Equals ( "System.ValueTuple" , StringComparison . OrdinalIgnoreCase ) ) . Single ( ) ;
518+ var runtimeAssemblies = valueTupleLibrary . RuntimeAssemblies . Where ( a => ! Path . GetFileName ( a . Path ) . Equals ( "_._" ) ) ;
519+ var compileTimeAssemblies = valueTupleLibrary . CompileTimeAssemblies . Where ( a => ! Path . GetFileName ( a . Path ) . Equals ( "_._" ) ) ;
520+
521+ if ( lockFileTarget . TargetFramework . Framework . Equals ( ".NETFramework" , StringComparison . OrdinalIgnoreCase ) )
522+ {
523+ runtimeAssemblies . Should ( ) . NotBeEmpty ( ) ;
524+ compileTimeAssemblies . Should ( ) . NotBeEmpty ( ) ;
525+ }
526+ else
527+ {
528+ runtimeAssemblies . Should ( ) . BeEmpty ( ) ;
529+ compileTimeAssemblies . Should ( ) . BeEmpty ( ) ;
530+ }
531+ }
532+ }
533+
495534 static List < KeyValuePair < string , string > > ParsePrunePackageReferenceJson ( string json )
496535 {
497536 List < KeyValuePair < string , string > > ret = new ( ) ;
0 commit comments