phmonte / Buildalyzer

A utility to perform design-time builds of .NET projects without having to think too hard about it.
MIT License
611 stars 94 forks source link

Missed dependency? #116

Closed davidehnis closed 2 years ago

davidehnis commented 5 years ago

Greetings! It looks like you may have missed a dependency. I had to install package "System.Reflection.TypeExtensions" to get it to work. Installing this resolved exception and it all works like a charm.

daveaglick commented 5 years ago

Interesting - what exact error were you seeing (at run time or build time?) and what was the target of the consuming application? It's entirely possible I need to adjust the dependencies for some set of consumers based on their target, especially if they're .NET Framework apps.

hrannzo commented 5 years ago

Happened to my as well while running console application targeting net472.

The code:

var manager = new AnalyzerManager();
var analyzer = manager.GetProject(projectPath);
var results = analyzer.Build(); // throws here

The exception info:

System.IO.FileNotFoundException
  HResult=0x80070002
  Message=Could not load file or assembly 'System.Reflection.TypeExtensions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
  Source=MsBuildPipeLogger.Server
  StackTrace:
   at MsBuildPipeLogger.BuildEventArgsReaderProxy..ctor(BinaryReader reader)
   at MsBuildPipeLogger.PipeLoggerServer`1..ctor(TPipeStream pipeStream, CancellationToken cancellationToken)
   at Buildalyzer.ProjectAnalyzer.BuildTargets(BuildEnvironment buildEnvironment, String targetFramework, String[] targetsToBuild, AnalyzerResults results)
   at Buildalyzer.ProjectAnalyzer.Build(String targetFramework, BuildEnvironment buildEnvironment)
   at Buildalyzer.ProjectAnalyzer.Build(String targetFramework)
   at Buildalyzer.ProjectAnalyzer.Build()
daveaglick commented 5 years ago

I added System.Reflection.TypeExtensions as a direct dependency to the next version (it was already coming in via transitive dependencies). Hopefully that resolves the issue - I'll close it out but please let me know if the direct package reference is still needed after upgrading to 2.3.1.

vladimir-angelov-1337 commented 4 years ago
//System.IO.FileNotFoundException: Could not load file or assembly 'System.Reflection.TypeExtensions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
//File name: 'System.Reflection.TypeExtensions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
//   at MsBuildPipeLogger.BuildEventArgsReaderProxy..ctor(BinaryReader reader)
//   at MsBuildPipeLogger.PipeLoggerServer`1..ctor(TPipeStream pipeStream, CancellationToken cancellationToken)
//   at Buildalyzer.ProjectAnalyzer.BuildTargets(BuildEnvironment buildEnvironment, String targetFramework, String[] targetsToBuild, AnalyzerResults results)
//   at Buildalyzer.ProjectAnalyzer.Build(String targetFramework, BuildEnvironment buildEnvironment)
//   at Buildalyzer.ProjectAnalyzer.Build(String targetFramework)
//   at Buildalyzer.ProjectAnalyzer.Build()
//   at HTMLXCompiler.Shared.ControllersBuilder.<FindTypesInProjectAsync>d__7.MoveNext()
//--- End of stack trace from previous location where exception was thrown ---
//   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
//   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
//   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
//   at HTMLXCompiler.Shared.ControllersBuilder.<GenerateControllersCodeAsync>d__6.MoveNext()
daveaglick commented 4 years ago

Hi @TriEdgeAI - what version of Buildalyzer is this (the latest?), what version of .NET Core (or Framework) is the app running on, and what’s the target of the project being compiled? That’ll help me get to the bottom of why you might be seeing this. Thanks!

vladimir-angelov-1337 commented 4 years ago

image

image

image

vladimir-angelov-1337 commented 4 years ago

Is this useful?

vladimir-angelov-1337 commented 4 years ago

I'm getting this

NU1605: Detected package downgrade: System.Reflection.TypeExtensions from 4.6.0 to 4.1.0. Reference the package directly from the project to select a different version. 
 HTMLX.VisualStudio -> Buildalyzer 2.6.0 -> System.Reflection.TypeExtensions (>= 4.6.0) 
 HTMLX.VisualStudio -> System.Reflection.TypeExtensions (>= 4.1.0)

When I tried referencing 4.1.0 manually as a NuGet package.

daveaglick commented 4 years ago

Very useful, thanks. I have an idea what the problem might be - I’ll check it out tomorrow and see if I can replicate/fix. Stay tuned.

daveaglick commented 2 years ago

I'm pretty sure this was fixed a while ago so I'm going to assume this issue is either resolved or no longer relevant. Please comment or open a new issue if that's incorrect and you're still having trouble.