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

InvalidOperationException thrown #31

Open
rockfordlhotka opened this issue Nov 20, 2023 · 3 comments
Open

InvalidOperationException thrown #31

rockfordlhotka opened this issue Nov 20, 2023 · 3 comments

Comments

@rockfordlhotka
Copy link

I attempted to use the tool against the main branch of the CSLA .NET project (Source/csla.build.sln) and got this exception:

dotnet depends ./csla.build.sln

Unhandled exception. System.InvalidOperationException: Sequence contains no matching element
   at System.Linq.ThrowHelper.ThrowNoMatchException()
   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
   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 256
   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

This solution builds a wide range of projects, most UI types, class libraries, netfx, net8.0, and more. I don't see in the exception where there's any indication of which project caused the failure. Let me know if I can provide assistance.

@bjorkstromm
Copy link
Owner

Hi, tried reproducing. But as I don't have MAUI workload installed, I'm not even able to do the design-time build.

Platform version is not present for one or more target frameworks, even though they have specified a platform: net8.0-android, net8.0-ios, net8.0-maccatalyst
Unhandled exception. System.Collections.Generic.KeyNotFoundException: The given key 'Microsoft.Maui.Controls' was not present in the dictionary.

So I don't have to install the MAUI workloads on my machine, would you mind debugging Depends for me? Place a breakpoint around here

var targetFramework = analyzerResult.GetTargetFramework();
var runtimeIdentifier = analyzerResult.GetRuntimeIdentifier();
var libraries = lockFile.Targets.Single(
x => x.TargetFramework == targetFramework && x.RuntimeIdentifier == runtimeIdentifier)
.Libraries.Where(x => x.IsPackage()).ToList();
and tell me the values of targetFramework, runtimeIdentifier, and lockFile.Targets 😄

@rockfordlhotka
Copy link
Author

Thank you for the reply, I'll give that a try and let you know.

@rockfordlhotka
Copy link
Author

rockfordlhotka commented Jan 31, 2024

targetFramework is net6.0
runtimeIdentifier is null
lockFile.Targets

? lockFile.Targets[0]
{NuGet.ProjectModel.LockFileTarget}
    Libraries: Count = 21
    Name: "net6.0"
    RuntimeIdentifier: null
    TargetFramework: {net6.0}
? lockFile.Targets[1]
{NuGet.ProjectModel.LockFileTarget}
    Libraries: Count = 20
    Name: "net7.0"
    RuntimeIdentifier: null
    TargetFramework: {net7.0}
? lockFile.Targets[2]
{NuGet.ProjectModel.LockFileTarget}
    Libraries: Count = 22
    Name: "net8.0"
    RuntimeIdentifier: null
    TargetFramework: {net8.0}

The list of libraries in the net6.0 target is:

"Microsoft.Build.Tasks.Git\r\nMicrosoft.Extensions.Configuration\r\nMicrosoft.Extensions.Configuration.Abstractions\r\nMicrosoft.Extensions.Configuration.Binder\r\nMicrosoft.Extensions.DependencyInjection\r\nMicrosoft.Extensions.DependencyInjection.Abstractions\r\nMicrosoft.Extensions.FileProviders.Abstractions\r\nMicrosoft.Extensions.Hosting.Abstractions\r\nMicrosoft.Extensions.Logging.Abstractions\r\nMicrosoft.Extensions.Primitives\r\nMicrosoft.SourceLink.Common\r\nMicrosoft.SourceLink.GitHub\r\nSystem.ComponentModel.Annotations\r\nSystem.Runtime.CompilerServices.Unsafe\r\n"

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

2 participants