Buildalyzer
Buildalyzer copied to clipboard
Buildalyzer could not load files or assemblies
I'm using Buildalyzer to load projects in a given solution to perform some analysis on the projects' documents. I'm trying to test my implementation on its own solution, but it's showing some weird behaviours:
- One of the projects in the solution, the project that actually uses buildalyzer, seems to throw an IOException when being built. This exception is thrown in the Buildalyzer.TargetFrameworkComparer class. For some reason, it cannot find the reference to NuGet.Frameworks.
- When the project above is not built first, the project seems to build properly.
- I'm experiencing the same issue with some other nuget packages (EPPlus in my case).
When I build the project in Visual Studio 2022, everything works fine. I'm stuck on where this problem is coming from and how to proceed. Is this expected behaviour, or some bug? Is there something I'm missing that I need to fix?
An update: I copied the solution and the faulty project to a new solution. When I run my implementation on the copy, it all works. So I assume the exception has to do with the project trying to build itself again at runtime. Is this intended, or is there still a workaround to this?
So I assume the exception has to do with the project trying to build itself again at runtime. Is this intended, or is there still a workaround to this?
By default Buildalyzer calls MSBuild (or dotnet build
depending on .NET Core vs. Framework, which indirectly calls MSBuild anyway). It tried to do this as closely to a "normal" build as possible - over the years I've discovered that the more Buildalyzer deviates from that, the more problems arise. However, this does create a separate class of problem as you've noticed because it'll shell out to MSBuild, which then tries to build in the normal place. If you're running the application from there at the same time I'd expect some oddness like locked files, etc.
The trick is probably to change the output path, intermediate path, etc. for your particular use case. For more context and some examples see https://github.com/daveaglick/Buildalyzer/issues/105 - let me know if that helps at all.
Just checking in - have you had any luck with the suggestions above?
@Liam-Rougoor ?