@@ -162,12 +162,10 @@ string[] Unscannable(string? detail) {
162162 var assets = new Assets ( PackageResolver ( lockFile ) , libraries , projectKeys , projectNames ) ;
163163
164164 var isTest = IsTestProject ( project ) ;
165- var frameworks = new List < string > ( ) ;
166165 foreach ( var target in NuGetShim . Seq < LockFileTarget > ( lockFile , "Targets" ) ) {
167- var alias = EmitTarget ( info , spec , target , assets , isTest ) ;
168- if ( alias != null && string . IsNullOrEmpty ( target . RuntimeIdentifier ) ) frameworks . Add ( alias ) ;
166+ EmitTarget ( info , spec , target , assets , isTest ) ;
169167 }
170- if ( _opts . WithFiles ) EmitPaths ( info , project , frameworks ) ;
168+ if ( _opts . WithFiles ) EmitPaths ( info , project ) ;
171169 return references ;
172170 }
173171
@@ -227,9 +225,8 @@ private static bool IsTestProject(Project project) {
227225 || project . GetPropertyValue ( "ProjectTypeGuids" ) . Contains ( TestProjectTypeGuid , StringComparison . OrdinalIgnoreCase ) ;
228226 }
229227
230- // One resolution root per (target framework [/ runtime], prod|dev). Returns
231- // the target framework alias when the target was read.
232- private string ? EmitTarget ( ProjectInfo info , PackageSpec spec , LockFileTarget target , Assets assets , bool isTest ) {
228+ // One resolution root per (target framework [/ runtime], prod|dev).
229+ private void EmitTarget ( ProjectInfo info , PackageSpec spec , LockFileTarget target , Assets assets , bool isTest ) {
233230 var framework = NuGetShim . Seq < TargetFrameworkInformation > ( spec , "TargetFrameworks" )
234231 . FirstOrDefault ( f => f . FrameworkName . Equals ( target . TargetFramework ) ) ;
235232 var alias = framework ? . TargetAlias ;
@@ -239,7 +236,7 @@ private static bool IsTestProject(Project project) {
239236 // A runtime-specific target also answers to its framework's name, so a
240237 // filter on `net8.0` covers `net8.0/win-x64`.
241238 var names = string . IsNullOrEmpty ( rid ) ? new [ ] { config } : new [ ] { config , alias } ;
242- if ( ! _configs . Matches ( names ) ) return null ;
239+ if ( ! _configs . Matches ( names ) ) return ;
243240 if ( _scanned . Add ( config ) ) _records . Scanned ( config ) ;
244241
245242 var libraries = new Dictionary < string , LockFileTargetLibrary > ( StringComparer . Ordinal ) ;
@@ -331,7 +328,6 @@ void EmitRoot(string kind, bool prod, HashSet<string> ids, bool withFiles) {
331328 // project resolves is dev.
332329 EmitRoot ( "all" , false , reached , _opts . WithFiles ) ;
333330 if ( ! isTest ) EmitRoot ( "prod" , true , shipped , false ) ;
334- return alias ;
335331 }
336332
337333 // Runtime assemblies (lib/, runtimes/<rid>/lib/) carry the method bodies an
@@ -454,7 +450,7 @@ private void ReadPackagesConfig(ProjectInfo info, Project project, string packag
454450 }
455451 if ( packages . Count == 0 ) return ;
456452 var config = LegacyFrameworkName ( project ) ;
457- if ( ! _configs . Matches ( new [ ] { config } ) ) return ;
453+ if ( ! _configs . Matches ( config ) ) return ;
458454 if ( _scanned . Add ( config ) ) _records . Scanned ( config ) ;
459455
460456 var isTest = IsTestProject ( project ) ;
@@ -528,13 +524,11 @@ private static string NormalizeSlashes(string path) {
528524
529525 // NuGet's short folder name of a build's framework, as restore derives it
530526 // from the two monikers; null when unrecognized.
531- private static string ? ShortFrameworkName ( Project build ) =>
532- ShortFrameworkName ( build . GetPropertyValue ( "TargetFrameworkMoniker" ) , build . GetPropertyValue ( "TargetPlatformMoniker" ) ) ;
533-
534- private static string ? ShortFrameworkName ( string moniker , string platformMoniker ) {
527+ private static string ? ShortFrameworkName ( Project build ) {
528+ var moniker = build . GetPropertyValue ( "TargetFrameworkMoniker" ) ;
535529 if ( string . IsNullOrEmpty ( moniker ) ) return null ;
536530 try {
537- return NuGetFramework . ParseComponents ( moniker , platformMoniker ) . GetShortFolderName ( ) ;
531+ return NuGetFramework . ParseComponents ( moniker , build . GetPropertyValue ( "TargetPlatformMoniker" ) ) . GetShortFolderName ( ) ;
538532 } catch ( ArgumentException ) {
539533 return null ;
540534 }
@@ -547,41 +541,39 @@ private static string LegacyFrameworkName(Project project) {
547541 return string . IsNullOrEmpty ( version ) ? "unknown" : $ "net{ version . TrimStart ( 'v' ) . Replace ( "." , "" ) } ";
548542 }
549543
550- // The inner builds of a multi-targeting project, by target framework; none
551- // for a project with a single framework.
544+ // Split as Microsoft.Common.CrossTargeting.targets does: trimmed, distinct
545+ // ignoring case. Empty for a single- framework project .
552546 private static List < string > Frameworks ( Project project ) {
553547 var multi = project . GetPropertyValue ( "TargetFrameworks" ) ;
554548 if ( string . IsNullOrEmpty ( project . GetPropertyValue ( "TargetFramework" ) ) && ! string . IsNullOrEmpty ( multi ) ) {
555- return multi . Split ( ';' ) . Select ( f => f . Trim ( ) ) . Where ( f => f . Length > 0 ) . Distinct ( ) . ToList ( ) ;
549+ return multi . Split ( ';' ) . Select ( f => f . Trim ( ) ) . Where ( f => f . Length > 0 ) . Distinct ( StringComparer . OrdinalIgnoreCase ) . ToList ( ) ;
556550 }
557551 return new List < string > ( ) ;
558552 }
559553
560554 // Per inner build of a multi-targeting project, whose outer evaluation has
561555 // no Compile items or TargetPath, or of the project's single framework.
562- // `frameworks`: the inner builds to read, when restore names them.
563- private void EmitPaths ( ProjectInfo info , Project project , List < string > ? frameworks = null ) {
556+ private void EmitPaths ( ProjectInfo info , Project project ) {
564557 var multi = Frameworks ( project ) ;
565558 if ( multi . Count == 0 ) {
566559 var single = project . GetPropertyValue ( "TargetFramework" ) ;
567560 var config = string . IsNullOrEmpty ( single ) ? LegacyFrameworkName ( project ) : single ;
568- if ( _configs . Matches ( new [ ] { config } ) ) EmitBuild ( info , project , config ) ;
561+ if ( _configs . Matches ( config ) ) EmitBuild ( info , project , config ) ;
569562 return ;
570563 }
571- foreach ( var tfm in ( frameworks ?? multi ) . Where ( f => _configs . Matches ( new [ ] { f } ) ) ) {
564+ foreach ( var tfm in multi . Where ( _configs . Matches ) ) {
572565 Project build ;
573566 try {
574567 build = LoadInnerBuild ( project , tfm ) ;
575568 } catch ( InvalidProjectFileException e ) {
576- _records . Unscannable ( tfm , $ "could not evaluate the { tfm } build: { Text . FirstLine ( e . Message ) } ", info . Key ) ;
569+ _records . Unscannable ( tfm , $ "could not evaluate the { tfm } build: { ErrorText ( e ) } ", info . Key ) ;
577570 continue ;
578571 }
579572 EmitBuild ( info , build , tfm ) ;
580573 }
581574 }
582575
583- // As evaluation leaves it: no target runs, so neither the sources targets
584- // generate nor the references and analyzers they resolve are known.
576+ // As evaluation leaves it: sources that targets generate are absent.
585577 private void EmitBuild ( ProjectInfo info , Project build , string config ) {
586578 var language = build . GetPropertyValue ( "Language" ) ;
587579 var isFSharp = string . Equals ( language , "F#" , StringComparison . OrdinalIgnoreCase ) ;
0 commit comments