@@ -496,6 +496,57 @@ await SimpleTestPackageUtility.CreatePackagesAsync(
496496 return await RunRestoreAsync ( pathContext , projectSpec ) ;
497497 }
498498
499+ [ Fact ]
500+ public async Task RestoreCommand_SDKProjectWithMissingAliases_UsesV3AssetsFile ( )
501+ {
502+ using var pathContext = new SimpleTestPathContext ( ) ;
503+ PackageSpec projectSpec = GetSDKPackageSpecWithMissingAlias ( pathContext ) ;
504+
505+ await SimpleTestPackageUtility . CreatePackagesAsync (
506+ pathContext . PackageSource ,
507+ new SimpleTestPackageContext ( "x" , "1.0.0" ) ) ;
508+
509+ // Act & Assert
510+ var result = await RunRestoreAsync ( pathContext , projectSpec ) ;
511+ result . Success . Should ( ) . BeTrue ( ) ;
512+ result . LockFile . Targets . Should ( ) . HaveCount ( 1 ) ;
513+ result . LockFile . Targets [ 0 ] . TargetAlias . Should ( ) . Be ( string . Empty ) ;
514+ result . LockFile . Targets [ 0 ] . Libraries . Should ( ) . HaveCount ( 1 ) ;
515+ result . LockFile . Targets [ 0 ] . Libraries [ 0 ] . Name . Should ( ) . Be ( "x" ) ;
516+ result . LockFile . Version . Should ( ) . Be ( 3 ) ;
517+ }
518+
519+ private static PackageSpec GetSDKPackageSpecWithMissingAlias ( SimpleTestPathContext pathContext )
520+ {
521+ var rootProject = @"
522+ {
523+ ""frameworks"": {
524+ ""net10.0"": {
525+ ""framework"": ""net10.0"",
526+ ""dependencies"": {
527+ ""x"": {
528+ ""version"": ""[1.0.0,)"",
529+ ""target"": ""Package"",
530+ }
531+ }
532+ }
533+ }
534+ }" ;
535+
536+
537+ // Setup project
538+ 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 ;
548+ }
549+
499550 internal static Task < RestoreResult > RunRestoreAsync ( SimpleTestPathContext pathContext , params PackageSpec [ ] projects )
500551 {
501552 return RunRestoreAsync ( pathContext , forceEvaluate : false , new TestLogger ( ) , projects ) ;
0 commit comments