Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for KeyNotFoundException when a package dependency does not appear in the list of libraries taken from the lock file #26

Merged
merged 5 commits into from
Mar 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/Depends.Core/DependencyAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,20 @@ private DependencyGraph.Builder CreateBuilder(IProjectAnalyzer projectAnalyzer,
{
var libraryNode = library.ToNode();
builder.WithNode(libraryNode);
libraryNodes.Add(libraryNode.PackageId, libraryNode);

// Overwrite any previous additions that may have been added by the loop below.
libraryNodes[libraryNode.PackageId] = libraryNode;

// Not all dependencies are necessarily included in the list of libraries
// for the current target framework and runtime identifier. Add these to libraryNodes
// so we can still record these dependencies.
foreach (var dependency in library.Dependencies)
{
// Add min version in version range if this dependency doesn't exist
libraryNodes.TryAdd(
dependency.Id,
new PackageReferenceNode(dependency.Id, dependency.VersionRange.MinVersion.ToString()));
}

if (library.FrameworkAssemblies.Count > 0)
{
Expand Down Expand Up @@ -297,6 +310,7 @@ private DependencyGraph.Builder CreateBuilder(IProjectAnalyzer projectAnalyzer,
//}
}


foreach (var library in libraries)
{
var libraryNode = library.ToNode();
Expand Down