@@ -546,7 +546,7 @@ await SimpleTestPackageUtility.CreatePackagesAsync(
546546 [ InlineData ( "apple" , "net9.0" , "banana" , "net10.0" ) ]
547547 [ InlineData ( "apple" , "net10.0" , "banana" , "net10.0" ) ]
548548 [ InlineData ( "banana" , "net10.0" , "apple" , "net10.0" ) ]
549- public async Task RestoreCommand_WithAliasesOfDifferentFramework_WithConditionalWarningSuppression_SupressesWarningsCorrectly ( string firstAlias , string firstFramework , string secondAlias , string secondFramework )
549+ public async Task RestoreCommand_WithAliases_WithConditionalWarningSuppression_SupressesWarningsCorrectly ( string firstAlias , string firstFramework , string secondAlias , string secondFramework )
550550 {
551551 using var pathContext = new SimpleTestPathContext ( ) ;
552552 var rootProject = @"
@@ -596,6 +596,83 @@ await SimpleTestPackageUtility.CreatePackagesAsync(
596596 result . LockFile . LogMessages [ 0 ] . TargetGraphs . Should ( ) . BeEquivalentTo ( [ firstAlias ] ) ;
597597 }
598598
599+ // P (apple) -> Project2 (apple) -> Package A
600+ // P (banana) -> Project2 (banana) -> Package B
601+ [ Fact ]
602+ public async Task RestoreCommand_WithAliasesOfSameFrameworkAndProjectReferences_WithConditionalWarningSuppression_SupressesWarningsCorrectly ( )
603+ {
604+ using var pathContext = new SimpleTestPathContext ( ) ;
605+
606+ // Create packages
607+ var pkgA = new SimpleTestPackageContext ( "PackageA" , "1.0.1" ) ;
608+ var pkgB = new SimpleTestPackageContext ( "PackageB" , "1.0.1" ) ;
609+ await SimpleTestPackageUtility . CreatePackagesAsync ( pathContext . PackageSource , pkgA , pkgB ) ;
610+
611+ string apple = nameof ( apple ) ;
612+ string banana = nameof ( banana ) ;
613+
614+ // Create Project2 spec with different package dependencies per alias
615+ var project2Spec = @"
616+ {
617+ ""frameworks"": {
618+ ""apple"": {
619+ ""framework"": ""net10.0"",
620+ ""targetAlias"": ""apple"",
621+ ""dependencies"": {
622+ ""PackageA"": {
623+ ""version"": ""[1.0.0,)"",
624+ ""target"": ""Package"",
625+ ""noWarn"": [""NU1603""]
626+ }
627+ }
628+ },
629+ ""banana"": {
630+ ""framework"": ""net10.0"",
631+ ""targetAlias"": ""banana"",
632+ ""dependencies"": {
633+ ""PackageB"": {
634+ ""version"": ""[1.0.0,)"",
635+ ""target"": ""Package"",
636+ }
637+ }
638+ }
639+ }
640+ }" ;
641+
642+ var project2 = ProjectTestHelpers . GetPackageSpecWithProjectNameAndSpec ( "Project2" , pathContext . SolutionRoot , project2Spec ) ;
643+
644+ // Create Project1 spec that references Project2
645+ var project1Spec = @"
646+ {
647+ ""frameworks"": {
648+ ""apple"": {
649+ ""framework"": ""net10.0"",
650+ ""targetAlias"": ""apple"",
651+ ""dependencies"": {
652+ }
653+ },
654+ ""banana"": {
655+ ""framework"": ""net10.0"",
656+ ""targetAlias"": ""banana"",
657+ ""dependencies"": {
658+ }
659+ }
660+ }
661+ }" ;
662+
663+ var project1 = ProjectTestHelpers . GetPackageSpecWithProjectNameAndSpec ( "Project1" , pathContext . SolutionRoot , project1Spec ) ;
664+ project1 = project1 . WithTestProjectReference ( project2 ) ;
665+
666+ // Act
667+ var result = await RunRestoreAsync ( pathContext , project1 , project2 ) ;
668+
669+ // Assert
670+ result . Success . Should ( ) . BeTrue ( ) ;
671+ result . LockFile . Targets . Should ( ) . HaveCount ( 2 ) ;
672+ result . LockFile . LogMessages . Should ( ) . HaveCount ( 1 ) ;
673+ result . LockFile . LogMessages [ 0 ] . TargetGraphs . Should ( ) . BeEquivalentTo ( [ banana ] ) ;
674+ }
675+
599676 internal static Task < RestoreResult > RunRestoreAsync ( SimpleTestPathContext pathContext , params PackageSpec [ ] projects )
600677 {
601678 return RunRestoreAsync ( pathContext , forceEvaluate : false , new TestLogger ( ) , projects ) ;
0 commit comments