@@ -500,7 +500,32 @@ await SimpleTestPackageUtility.CreatePackagesAsync(
500500 public async Task RestoreCommand_SDKProjectWithMissingAliases_UsesV3AssetsFile ( )
501501 {
502502 using var pathContext = new SimpleTestPathContext ( ) ;
503- PackageSpec projectSpec = GetSDKPackageSpecWithMissingAlias ( pathContext ) ;
503+ var rootProject = @"
504+ {
505+ ""frameworks"": {
506+ ""net10.0"": {
507+ ""framework"": ""net10.0"",
508+ ""dependencies"": {
509+ ""x"": {
510+ ""version"": ""[1.0.0,)"",
511+ ""target"": ""Package"",
512+ }
513+ }
514+ }
515+ }
516+ }" ;
517+
518+
519+ // Setup project
520+ var projectSpec = ProjectTestHelpers . GetPackageSpecWithProjectNameAndSpec ( "Project1" , pathContext . SolutionRoot , rootProject ) ;
521+ // pre-conditions
522+ projectSpec . RestoreMetadata . UsingMicrosoftNETSdk = true ;
523+ projectSpec . RestoreMetadata . SdkAnalysisLevel = NuGetVersion . Parse ( "10.0.400" ) ;
524+ projectSpec . TargetFrameworks [ 0 ] = new TargetFrameworkInformation ( projectSpec . TargetFrameworks [ 0 ] )
525+ {
526+ TargetAlias = string . Empty
527+ } ;
528+ projectSpec . RestoreMetadata . TargetFrameworks [ 0 ] . TargetAlias = string . Empty ;
504529
505530 await SimpleTestPackageUtility . CreatePackagesAsync (
506531 pathContext . PackageSource ,
@@ -516,35 +541,59 @@ await SimpleTestPackageUtility.CreatePackagesAsync(
516541 result . LockFile . Version . Should ( ) . Be ( 3 ) ;
517542 }
518543
519- private static PackageSpec GetSDKPackageSpecWithMissingAlias ( SimpleTestPathContext pathContext )
544+ [ Theory ]
545+ [ InlineData ( "net9.0" , "net9.0" , "net10.0" , "net10.0" ) ]
546+ [ InlineData ( "apple" , "net9.0" , "banana" , "net10.0" ) ]
547+ [ InlineData ( "apple" , "net10.0" , "banana" , "net10.0" ) ]
548+ [ InlineData ( "banana" , "net10.0" , "apple" , "net10.0" ) ]
549+ public async Task RestoreCommand_WithAliasesOfDifferentFramework_WithConditionalWarningSuppression_SupressesWarningsCorrectly ( string firstAlias , string firstFramework , string secondAlias , string secondFramework )
520550 {
551+ using var pathContext = new SimpleTestPathContext ( ) ;
521552 var rootProject = @"
522553 {
523554 ""frameworks"": {
524- ""net10.0"": {
525- ""framework"": ""net10.0"",
555+ ""apple"": {
556+ ""framework"": ""TFM1"",
557+ ""targetAlias"": ""ALIAS1"",
526558 ""dependencies"": {
527559 ""x"": {
528560 ""version"": ""[1.0.0,)"",
529561 ""target"": ""Package"",
530562 }
531563 }
564+ },
565+ ""banana"": {
566+ ""framework"": ""TFM2"",
567+ ""targetAlias"": ""ALIAS2"",
568+ ""dependencies"": {
569+ ""x"": {
570+ ""version"": ""[1.0.0,)"",
571+ ""target"": ""Package"",
572+ ""noWarn"": [""NU1603""]
573+ }
574+ }
532575 }
533576 }
534- }" ;
535-
577+ }"
578+ . Replace ( "ALIAS1" , firstAlias )
579+ . Replace ( "TFM1" , firstFramework )
580+ . Replace ( "ALIAS2" , secondAlias )
581+ . Replace ( "TFM2" , secondFramework ) ;
536582
537583 // Setup project
538584 var projectSpec = ProjectTestHelpers . GetPackageSpecWithProjectNameAndSpec ( "Project1" , pathContext . SolutionRoot , rootProject ) ;
539- // pre-conditions
540- projectSpec . RestoreMetadata . UsingMicrosoftNETSdk = true ;
541- projectSpec . RestoreMetadata . SdkAnalysisLevel = NuGetVersion . Parse ( "10.0.400" ) ;
542- projectSpec . TargetFrameworks [ 0 ] = new TargetFrameworkInformation ( projectSpec . TargetFrameworks [ 0 ] )
543- {
544- TargetAlias = string . Empty
545- } ;
546- projectSpec . RestoreMetadata . TargetFrameworks [ 0 ] . TargetAlias = string . Empty ;
547- return projectSpec ;
585+ await SimpleTestPackageUtility . CreatePackagesAsync (
586+ pathContext . PackageSource ,
587+ new SimpleTestPackageContext ( "x" , "1.0.1" ) ) ;
588+
589+ // Act & Assert
590+ var result = await RunRestoreAsync ( pathContext , projectSpec ) ;
591+ result . Success . Should ( ) . BeTrue ( ) ;
592+ result . LockFile . Targets . Should ( ) . HaveCount ( 2 ) ;
593+ result . LockFile . Targets [ 0 ] . Libraries . Should ( ) . HaveCount ( 1 ) ;
594+ result . LockFile . Targets [ 1 ] . Libraries . Should ( ) . HaveCount ( 1 ) ;
595+ result . LockFile . LogMessages . Should ( ) . HaveCount ( 1 ) ;
596+ result . LockFile . LogMessages [ 0 ] . TargetGraphs . Should ( ) . BeEquivalentTo ( [ firstAlias ] ) ;
548597 }
549598
550599 internal static Task < RestoreResult > RunRestoreAsync ( SimpleTestPathContext pathContext , params PackageSpec [ ] projects )
0 commit comments