@@ -77,21 +77,6 @@ public DependencyManager(string srcDir, IDependencyOptions options, ILogger logg
7777 ? allFiles . SelectFileNamesByExtension ( ".dll" ) . ToList ( )
7878 : options . DllDirs . Select ( Path . GetFullPath ) . ToList ( ) ;
7979
80- // Find DLLs in the .Net / Asp.Net Framework
81- if ( options . ScanNetFrameworkDlls )
82- {
83- var runtime = new Runtime ( dotnet ) ;
84- var runtimeLocation = runtime . GetRuntime ( options . UseSelfContainedDotnet ) ;
85- progressMonitor . LogInfo ( $ ".NET runtime location selected: { runtimeLocation } ") ;
86- dllDirNames . Add ( runtimeLocation ) ;
87-
88- if ( fileContent . UseAspNetDlls && runtime . GetAspRuntime ( ) is string aspRuntime )
89- {
90- progressMonitor . LogInfo ( $ "ASP.NET runtime location selected: { aspRuntime } ") ;
91- dllDirNames . Add ( aspRuntime ) ;
92- }
93- }
94-
9580 if ( options . UseNuGet )
9681 {
9782 dllDirNames . Add ( packageDirectory . DirInfo . FullName ) ;
@@ -111,6 +96,43 @@ public DependencyManager(string srcDir, IDependencyOptions options, ILogger logg
11196 DownloadMissingPackages ( allNonBinaryFiles ) ;
11297 }
11398
99+ // Find DLLs in the .Net / Asp.Net Framework
100+ if ( options . ScanNetFrameworkDlls )
101+ {
102+ // TODO: check if the nuget restore process has already downloaded any Core or Framework reference assemblies.
103+ // If so, we don't have to do the below.
104+ // `Microsoft.NETCore.App.Ref` or `Microsoft.NETFramework.ReferenceAssemblies.*`
105+
106+ var runtime = new Runtime ( dotnet ) ;
107+ string ? runtimeLocation = null ;
108+
109+ if ( options . UseSelfContainedDotnet )
110+ {
111+ runtimeLocation = runtime . ExecutingRuntime ;
112+ }
113+ else if ( fileContent . IsNewProjectStructureUsed )
114+ {
115+ runtimeLocation = runtime . NetCoreRuntime ;
116+ }
117+ else if ( fileContent . IsLegacyProjectStructureUsed )
118+ {
119+ runtimeLocation = runtime . DesktopRuntime ;
120+ }
121+
122+ runtimeLocation ??= runtime . ExecutingRuntime ;
123+
124+ progressMonitor . LogInfo ( $ ".NET runtime location selected: { runtimeLocation } ") ;
125+ dllDirNames . Add ( runtimeLocation ) ;
126+
127+ if ( fileContent . IsNewProjectStructureUsed
128+ && fileContent . UseAspNetCoreDlls
129+ && runtime . AspNetCoreRuntime is string aspRuntime )
130+ {
131+ progressMonitor . LogInfo ( $ "ASP.NET runtime location selected: { aspRuntime } ") ;
132+ dllDirNames . Add ( aspRuntime ) ;
133+ }
134+ }
135+
114136 assemblyCache = new AssemblyCache ( dllDirNames , progressMonitor ) ;
115137 AnalyseSolutions ( solutions ) ;
116138
@@ -198,7 +220,7 @@ private void GenerateSourceFileFromImplicitUsings()
198220 usings . UnionWith ( new [ ] { "System" , "System.Collections.Generic" , "System.IO" , "System.Linq" , "System.Net.Http" , "System.Threading" ,
199221 "System.Threading.Tasks" } ) ;
200222
201- if ( fileContent . UseAspNetDlls )
223+ if ( fileContent . UseAspNetCoreDlls )
202224 {
203225 usings . UnionWith ( new [ ] { "System.Net.Http.Json" , "Microsoft.AspNetCore.Builder" , "Microsoft.AspNetCore.Hosting" ,
204226 "Microsoft.AspNetCore.Http" , "Microsoft.AspNetCore.Routing" , "Microsoft.Extensions.Configuration" ,
0 commit comments