Skip to content

Commit 27f7f91

Browse files
ForgindMiYanni
andauthored
Update src/Tasks/Microsoft.NET.Build.Tasks/DependencyContextBuilder.cs
Co-authored-by: Michael Yanni <[email protected]>
1 parent c9d7a76 commit 27f7f91

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/Tasks/Microsoft.NET.Build.Tasks/DependencyContextBuilder.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -829,18 +829,17 @@ private void CalculateExcludedLibraries()
829829
while (dependencyListToWalk.Count != 0)
830830
{
831831
var dependencyName = dependencyListToWalk.Pop();
832-
if (!includedDependencies.ContainsKey(dependencyName) && _excludeFromPublishPackageIds?.Contains(dependencyName) != true)
832+
// There may not be a library in the assets file if a referenced project has
833+
// PrivateAssets="all" for a package reference, and there is a package in the graph
834+
// that depends on the same package.
835+
if (!includedDependencies.ContainsKey(dependencyName) &&
836+
_excludeFromPublishPackageIds?.Contains(dependencyName) != true &&
837+
_dependencyLibraries.TryGetValue(dependencyName, out var dependencyLibrary))
833838
{
834-
// There may not be a library in the assets file if a referenced project has
835-
// PrivateAssets="all" for a package reference, and there is a package in the graph
836-
// that depends on the same package.
837-
if (_dependencyLibraries.TryGetValue(dependencyName, out var dependencyLibrary))
839+
includedDependencies.Add(dependencyName, dependencyLibrary);
840+
foreach (var newDependency in _libraryDependencies[dependencyName])
838841
{
839-
includedDependencies.Add(dependencyName, dependencyLibrary);
840-
foreach (var newDependency in _libraryDependencies[dependencyName])
841-
{
842-
dependencyListToWalk.Push(newDependency.Name);
843-
}
842+
dependencyListToWalk.Push(newDependency.Name);
844843
}
845844
}
846845
}

0 commit comments

Comments
 (0)