@@ -194,27 +194,28 @@ public static bool IsPermissiveLicense(string? expression)
194194 x . Parts [ 2 ] . EndsWith ( ".dll" , StringComparison . OrdinalIgnoreCase ) )
195195 . ToList ( ) ;
196196
197- // Prefer the DLL matching the package name, fall back if there's exactly one DLL
198- var matchingEntries = allDllEntries
199- . Where ( x => x . Parts [ 2 ] . Equals ( expectedDll , StringComparison . OrdinalIgnoreCase ) )
200- . ToList ( ) ;
201-
202- if ( matchingEntries . Count == 0 && allDllEntries . Count == 1 )
203- matchingEntries = allDllEntries ;
204-
205- var tfmGroups = matchingEntries
197+ var tfmGroups = allDllEntries
206198 . GroupBy ( x => x . Parts [ 1 ] )
207- . OrderByDescending ( g => GetTfmPriority ( g . Key ) )
199+ . Select ( g =>
200+ {
201+ // Prefer the DLL matching the package name, fall back if there's exactly one DLL in the TFM
202+ var match = g . FirstOrDefault ( x => x . Parts [ 2 ] . Equals ( expectedDll , StringComparison . OrdinalIgnoreCase ) ) ;
203+ if ( match . Entry is null && g . Count ( ) == 1 )
204+ match = g . First ( ) ;
205+ return ( Tfm : g . Key , Entry : match ) ;
206+ } )
207+ . Where ( x => x . Entry . Entry is not null )
208+ . OrderByDescending ( x => GetTfmPriority ( x . Tfm ) )
208209 . ToList ( ) ;
209210
210- if ( tfmGroups . Count == 0 || GetTfmPriority ( tfmGroups [ 0 ] . Key ) < 0 )
211+ if ( tfmGroups . Count == 0 || GetTfmPriority ( tfmGroups [ 0 ] . Tfm ) < 0 )
211212 {
212213 File . Delete ( nupkgPath ) ;
213214 return ( null , null ) ;
214215 }
215216
216- selectedTfm = tfmGroups [ 0 ] . Key ;
217- var entry = tfmGroups [ 0 ] . First ( ) ;
217+ selectedTfm = tfmGroups [ 0 ] . Tfm ;
218+ var entry = tfmGroups [ 0 ] . Entry ;
218219
219220 string destPath = Path . Combine ( extractDir , entry . Parts [ 2 ] ) ;
220221 entry . Entry . ExtractToFile ( destPath , overwrite : true ) ;
0 commit comments