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

KeyNotFoundException for conflicts between a package reference and a project reference with the same name #34

Open
remoba opened this issue Jan 24, 2024 · 0 comments

Comments

@remoba
Copy link

remoba commented Jan 24, 2024

I have a scenario where I have an sln with the following hierarchy:

  • Project1 -> Project2 (ProjectReference)
  • Project1 -> Project2 (PackageReference)

(I realize this is not a standard practice, but I play around with MSBuild targets to copy different files from each of those dependencies)

When running dotnet depends on the sln, I am failing with this (Serilog being the placeholder ambiguous name):

Unhandled exception. System.Collections.Generic.KeyNotFoundException: The given key 'Serilog' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Depends.Core.DependencyAnalyzer.<>c__DisplayClass8_1.<CreateBuilder>b__7(ProjectItem x) in /home/runner/work/depends/depends/src/Depends.Core/DependencyAnalyzer.cs:line 328
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at Depends.Core.Graph.DependencyGraph.Builder.WithEdges(IEnumerable`1 edges) in /home/runner/work/depends/depends/src/Depends.Core/Graph/DependencyGraph.Builder.cs:line 23
   at Depends.Core.DependencyAnalyzer.CreateBuilder(IProjectAnalyzer projectAnalyzer, String projectPath, Builder builder, String framework) in /home/runner/work/depends/depends/src/Depends.Core/DependencyAnalyzer.cs:line 326
   at Depends.Core.DependencyAnalyzer.AnalyzeSolution(String solution, String framework) in /home/runner/work/depends/depends/src/Depends.Core/DependencyAnalyzer.cs:line 173
   at Depends.Program.GetDependencyGraph(ILoggerFactory loggerFactory) in /home/runner/work/depends/depends/src/Depends/Program.cs:line 132
   at Depends.Program.OnExecute() in /home/runner/work/depends/depends/src/Depends/Program.cs:line 114
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
--- End of stack trace from previous location ---
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.Invoke(MethodInfo method, Object instance, Object[] arguments)
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.OnExecute(ConventionContext context, CancellationToken cancellationToken)
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.<>c__DisplayClass0_0.<<Apply>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken)
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync[TApp](CommandLineContext context, CancellationToken cancellationToken)
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute[TApp](CommandLineContext context)
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute[TApp](IConsole console, String[] args)
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute[TApp](String[] args)
   at Depends.Program.Main(String[] args) in /home/runner/work/depends/depends/src/Depends/Program.cs:line 16

Not sure if this is solvable as both dependencies will ultimately produce the same dll name (I generally don't care about that because I don't consume that dll)

ErrorRepro2.zip

Attached is a simple repro of the problem, would appreciate any thoughts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant