@@ -128,24 +128,15 @@ public DependencyManager(string srcDir, IDependencyOptions options, ILogger logg
128
128
DownloadMissingPackages ( allNonBinaryFiles , dllPaths ) ;
129
129
}
130
130
131
- var frameworkLocations = new List < string > ( ) ;
131
+ var frameworkLocations = new HashSet < string > ( ) ;
132
132
133
133
// Find DLLs in the .Net / Asp.Net Framework
134
134
// This block needs to come after the nuget restore, because the nuget restore might fetch the .NET Core/Framework reference assemblies.
135
135
if ( options . ScanNetFrameworkDlls )
136
136
{
137
- var path = AddNetFrameworkDlls ( dllPaths ) ;
138
- frameworkLocations . Add ( path ) ;
139
- path = AddAspNetCoreFrameworkDlls ( dllPaths ) ;
140
- if ( path != null )
141
- {
142
- frameworkLocations . Add ( path ) ;
143
- }
144
- path = AddMicrosoftWindowsDesktopDlls ( dllPaths ) ;
145
- if ( path != null )
146
- {
147
- frameworkLocations . Add ( path ) ;
148
- }
137
+ AddNetFrameworkDlls ( dllPaths , frameworkLocations ) ;
138
+ AddAspNetCoreFrameworkDlls ( dllPaths , frameworkLocations ) ;
139
+ AddMicrosoftWindowsDesktopDlls ( dllPaths , frameworkLocations ) ;
149
140
}
150
141
151
142
assemblyCache = new AssemblyCache ( dllPaths , frameworkLocations , progressMonitor ) ;
@@ -239,7 +230,7 @@ private void RemoveNugetAnalyzerReferences()
239
230
}
240
231
}
241
232
242
- private string AddNetFrameworkDlls ( ISet < string > dllPaths )
233
+ private void AddNetFrameworkDlls ( ISet < string > dllPaths , ISet < string > frameworkLocations )
243
234
{
244
235
// Multiple dotnet framework packages could be present.
245
236
// The order of the packages is important, we're adding the first one that is present in the nuget cache.
@@ -252,14 +243,15 @@ private string AddNetFrameworkDlls(ISet<string> dllPaths)
252
243
if ( frameworkPath . Path is not null )
253
244
{
254
245
dllPaths . Add ( frameworkPath . Path ) ;
246
+ frameworkLocations . Add ( frameworkPath . Path ) ;
255
247
progressMonitor . LogInfo ( $ "Found .NET Core/Framework DLLs in NuGet packages at { frameworkPath . Path } . Not adding installation directory.") ;
256
248
257
249
for ( var i = frameworkPath . Index + 1 ; i < packagesInPrioOrder . Length ; i ++ )
258
250
{
259
251
RemoveNugetPackageReference ( packagesInPrioOrder [ i ] , dllPaths ) ;
260
252
}
261
253
262
- return frameworkPath . Path ;
254
+ return ;
263
255
}
264
256
265
257
string ? runtimeLocation = null ;
@@ -281,7 +273,7 @@ private string AddNetFrameworkDlls(ISet<string> dllPaths)
281
273
282
274
progressMonitor . LogInfo ( $ ".NET runtime location selected: { runtimeLocation } ") ;
283
275
dllPaths . Add ( runtimeLocation ) ;
284
- return runtimeLocation ;
276
+ frameworkLocations . Add ( runtimeLocation ) ;
285
277
}
286
278
287
279
private void RemoveNugetPackageReference ( string packagePrefix , ISet < string > dllPaths )
@@ -306,41 +298,38 @@ private void RemoveNugetPackageReference(string packagePrefix, ISet<string> dllP
306
298
}
307
299
}
308
300
309
- private string ? AddAspNetCoreFrameworkDlls ( ISet < string > dllPaths )
301
+ private void AddAspNetCoreFrameworkDlls ( ISet < string > dllPaths , ISet < string > frameworkLocations )
310
302
{
311
303
if ( ! fileContent . IsNewProjectStructureUsed || ! fileContent . UseAspNetCoreDlls )
312
304
{
313
- return null ;
305
+ return ;
314
306
}
315
307
316
308
// First try to find ASP.NET Core assemblies in the NuGet packages
317
309
if ( GetPackageDirectory ( FrameworkPackageNames . AspNetCoreFramework ) is string aspNetCorePackage )
318
310
{
319
311
progressMonitor . LogInfo ( $ "Found ASP.NET Core in NuGet packages. Not adding installation directory.") ;
320
312
dllPaths . Add ( aspNetCorePackage ) ;
321
- return aspNetCorePackage ;
313
+ frameworkLocations . Add ( aspNetCorePackage ) ;
314
+ return ;
322
315
}
323
316
324
317
if ( Runtime . AspNetCoreRuntime is string aspNetCoreRuntime )
325
318
{
326
319
progressMonitor . LogInfo ( $ "ASP.NET runtime location selected: { aspNetCoreRuntime } ") ;
327
320
dllPaths . Add ( aspNetCoreRuntime ) ;
328
- return aspNetCoreRuntime ;
321
+ frameworkLocations . Add ( aspNetCoreRuntime ) ;
329
322
}
330
-
331
- return null ;
332
323
}
333
324
334
- private string ? AddMicrosoftWindowsDesktopDlls ( ISet < string > dllPaths )
325
+ private void AddMicrosoftWindowsDesktopDlls ( ISet < string > dllPaths , ISet < string > frameworkLocations )
335
326
{
336
327
if ( GetPackageDirectory ( FrameworkPackageNames . WindowsDesktopFramework ) is string windowsDesktopApp )
337
328
{
338
329
progressMonitor . LogInfo ( $ "Found Windows Desktop App in NuGet packages.") ;
339
330
dllPaths . Add ( windowsDesktopApp ) ;
340
- return windowsDesktopApp ;
331
+ frameworkLocations . Add ( windowsDesktopApp ) ;
341
332
}
342
-
343
- return null ;
344
333
}
345
334
346
335
private string ? GetPackageDirectory ( string packagePrefix )
0 commit comments