@@ -24,6 +24,7 @@ public sealed class DependencyManager : IDisposable
2424 private readonly IDictionary < string , string > unresolvedReferences = new ConcurrentDictionary < string , string > ( ) ;
2525 private readonly List < string > nonGeneratedSources ;
2626 private readonly List < string > generatedSources ;
27+ private int dotnetFrameworkVersionVariantCount = 0 ;
2728 private int conflictedReferences = 0 ;
2829 private readonly IDependencyOptions options ;
2930 private readonly DirectoryInfo sourceDir ;
@@ -123,15 +124,15 @@ public DependencyManager(string srcDir, IDependencyOptions options, ILogger logg
123124 const int align = 6 ;
124125 logger . LogInfo ( "" ) ;
125126 logger . LogInfo ( "Build analysis summary:" ) ;
126- logger . LogInfo ( $ "{ this . nonGeneratedSources . Count , align } source files in the filesystem") ;
127- logger . LogInfo ( $ "{ this . generatedSources . Count , align } generated source files") ;
127+ logger . LogInfo ( $ "{ nonGeneratedSources . Count , align } source files in the filesystem") ;
128+ logger . LogInfo ( $ "{ generatedSources . Count , align } generated source files") ;
128129 logger . LogInfo ( $ "{ allSolutions . Count , align } solution files") ;
129130 logger . LogInfo ( $ "{ allProjects . Count , align } project files in the filesystem") ;
130131 logger . LogInfo ( $ "{ usedReferences . Keys . Count , align } resolved references") ;
131132 logger . LogInfo ( $ "{ unresolvedReferences . Count , align } unresolved references") ;
132133 logger . LogInfo ( $ "{ conflictedReferences , align } resolved assembly conflicts") ;
134+ logger . LogInfo ( $ "{ dotnetFrameworkVersionVariantCount , align } restored .NET framework variants") ;
133135 logger . LogInfo ( $ "Build analysis completed in { DateTime . Now - startTime } ") ;
134-
135136 }
136137
137138 private HashSet < string > AddFrameworkDlls ( HashSet < string > dllPaths )
@@ -241,11 +242,7 @@ private void RemoveNugetAnalyzerReferences()
241242
242243 private void SelectNewestFrameworkPath ( string frameworkPath , string frameworkType , ISet < string > dllPaths , ISet < string > frameworkLocations )
243244 {
244- var versionFolders = new DirectoryInfo ( frameworkPath )
245- . EnumerateDirectories ( "*" , new EnumerationOptions { MatchCasing = MatchCasing . CaseInsensitive , RecurseSubdirectories = false } )
246- . OrderByDescending ( d => d . Name ) // TODO: Improve sorting to handle pre-release versions.
247- . ToArray ( ) ;
248-
245+ var versionFolders = GetPackageVersionSubDirectories ( frameworkPath ) ;
249246 if ( versionFolders . Length > 1 )
250247 {
251248 var versions = string . Join ( ", " , versionFolders . Select ( d => d . Name ) ) ;
@@ -264,18 +261,34 @@ private void SelectNewestFrameworkPath(string frameworkPath, string frameworkTyp
264261 logger . LogInfo ( $ "Found { frameworkType } DLLs in NuGet packages at { selectedFrameworkFolder } .") ;
265262 }
266263
264+ private static DirectoryInfo [ ] GetPackageVersionSubDirectories ( string packagePath )
265+ {
266+ return new DirectoryInfo ( packagePath )
267+ . EnumerateDirectories ( "*" , new EnumerationOptions { MatchCasing = MatchCasing . CaseInsensitive , RecurseSubdirectories = false } )
268+ . OrderByDescending ( d => d . Name ) // TODO: Improve sorting to handle pre-release versions.
269+ . ToArray ( ) ;
270+ }
271+
267272 private void AddNetFrameworkDlls ( ISet < string > dllPaths , ISet < string > frameworkLocations )
268273 {
269274 // Multiple dotnet framework packages could be present.
270275 // The order of the packages is important, we're adding the first one that is present in the nuget cache.
271276 var packagesInPrioOrder = FrameworkPackageNames . NetFrameworks ;
272277
273- var frameworkPath = packagesInPrioOrder
278+ var frameworkPaths = packagesInPrioOrder
274279 . Select ( ( s , index ) => ( Index : index , Path : GetPackageDirectory ( s ) ) )
275- . FirstOrDefault ( pair => pair . Path is not null ) ;
280+ . Where ( pair => pair . Path is not null )
281+ . ToArray ( ) ;
282+
283+ var frameworkPath = frameworkPaths . FirstOrDefault ( ) ;
276284
277285 if ( frameworkPath . Path is not null )
278286 {
287+ foreach ( var fp in frameworkPaths )
288+ {
289+ dotnetFrameworkVersionVariantCount += GetPackageVersionSubDirectories ( fp . Path ! ) . Length ;
290+ }
291+
279292 SelectNewestFrameworkPath ( frameworkPath . Path , ".NET Framework" , dllPaths , frameworkLocations ) ;
280293
281294 for ( var i = frameworkPath . Index + 1 ; i < packagesInPrioOrder . Length ; i ++ )
0 commit comments