File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
src/Tasks/Microsoft.NET.Build.Tasks Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -317,7 +317,10 @@ public DependencyContext Build(string[] userRuntimeAssemblies = null)
317
317
{
318
318
foreach ( var dependency in reference . Library . Dependencies )
319
319
{
320
- references [ dependency . Name ] . Dependents . Add ( reference . Library . Name ) ;
320
+ if ( references . TryGetValue ( dependency . Name , out var dep ) )
321
+ {
322
+ dep . Dependents . Add ( reference . Library . Name ) ;
323
+ }
321
324
}
322
325
}
323
326
@@ -330,18 +333,24 @@ public DependencyContext Build(string[] userRuntimeAssemblies = null)
330
333
331
334
if ( lib . Library . RuntimeAssemblyGroups . Count == 0 && lib . Library . NativeLibraryGroups . Count == 0 && lib . Library . ResourceAssemblies . Count == 0 )
332
335
{
333
- if ( lib . Library . Dependencies . All ( d => ! references . ContainsKey ( d . Name ) || references [ d . Name ] . Dependents . Count > 1 ) )
336
+ if ( lib . Library . Dependencies . All ( d => ! references . TryGetValue ( d . Name , out var dependency ) || dependency . Dependents . Count > 1 ) )
334
337
{
335
338
runtimeLibraries . Remove ( lib ) ;
336
339
references . Remove ( lib . Library . Name ) ;
337
340
foreach ( var dependency in lib . Library . Dependencies )
338
341
{
339
- references [ dependency . Name ] . Dependents . Remove ( lib . Library . Name ) ;
342
+ if ( references . TryGetValue ( dependency . Name , out ModifiableRuntimeLibrary ? value ) )
343
+ {
344
+ value . Dependents . Remove ( lib . Library . Name ) ;
345
+ }
340
346
}
341
347
342
348
foreach ( var dependent in lib . Dependents )
343
349
{
344
- temp . Add ( references [ dependent ] ) ;
350
+ if ( references . TryGetValue ( dependent , out var dep ) )
351
+ {
352
+ temp . Add ( dep ) ;
353
+ }
345
354
}
346
355
}
347
356
}
You can’t perform that action at this time.
0 commit comments