phmonte / Buildalyzer

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

Add Referenced Projects #160

Closed slang25 closed 3 years ago

slang25 commented 3 years ago

Fixes #159

This change adds to the functionality when you set addProjectReferences to true. At the moment it will follow all references where you have already added the project to the solution, but if you want to create an ad-hoc solution with a csproj as the entry point, I think you'll want this behaviour to automatically add references projects to the solution.

Just to be clear, the code change code (in GetReferencedAnalyzerProjects) is only called when addProjectReferences is true.

slang25 commented 3 years ago

To counteract the guilt I'd feel bumping this PR, I bought you a coffee 😆

daveaglick commented 3 years ago

Lol. Was already planning to take a look at the open Buildalyzer PRs this weekend, but the beverage is appreciated!

slang25 commented 3 years ago

😄 it's the least I could do.

I think I may not need this anymore, what I need is basically this: https://github.com/aws/codelyzer/blob/acd3c02c4b41aa0a14393fcf0ae6f4f145212f97/src/Analysis/Codelyzer.Analysis.Build/WorkspaceBuilderHelper.cs#L74-L113

but I want it to happen out of the box. When I use this PR alone, doesn't give the right results from a clean build, because I've not built the projects in the right order.

daveaglick commented 3 years ago

Tell me more about

When I use this PR alone, doesn't give the right results from a clean build, because I've not built the projects in the right order.

Is the idea that sometimes analyzerResult.Manager.GetProject(x) won't have the project yet and so we need an extra flow where if the project hasn't already been added to the workspace, and the manager hasn't yet built it, we should go off and build it and then add it?

That seems totally doable, though I think you're right that we'd want to put that behind a flag (probably combined with the behavior in this PR - something like bool buildMissingReferences.

daveaglick commented 3 years ago

I guess the part I'm not quite understanding is:

So my disconnect is why that doesn't work as expected to build projects you're missing once this PR is merged.

daveaglick commented 3 years ago

I think I get it...is the problem that we don't pick up on transitive references? I.e. if I'm adding project A to the workspace and if references project B, I'll add and build B. But if B also references C, I'll never add and build C to the workspace.

daveaglick commented 3 years ago

I'm going to bring this discussion back to the original issue...