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

Resolve transitive packages? #135

Open
chucker opened this issue Apr 29, 2020 · 3 comments
Open

Resolve transitive packages? #135

chucker opened this issue Apr 29, 2020 · 3 comments
Labels
Discussion/Question Discussions or questions about the code

Comments

@chucker
Copy link

chucker commented Apr 29, 2020

I use Buildalyzer (and various other libraries) to check the state of a csproj. One of the steps is to add two package references if needed, where "needed" means:

  • the packages need to be referenced at all, and
  • in a version at least as high as the one I want

I can ask Buildalyzer for the existing package references and see if they're already in there, but one weakness in that approach is that it can still lead to "detected package downgrade" warnings, because there might be a different package reference that implicitly gets a newer version.

Is there any way to have Buildalyzer give me a flat list (or tree would be OK, too) of all package references including transitive ones? I assume this would involve invoking a design-time build, parsing project.assets.json or similar?

@daveaglick daveaglick added the Discussion/Question Discussions or questions about the code label May 1, 2020
@daveaglick
Copy link
Collaborator

I assume this would involve invoking a design-time build, parsing project.assets.json or similar?

Exactly right - that data isn't surfaced directly by MSBuild so Buildalyzer doesn't have access to it. However, @mholo65 has done all the heavy lifting to do exactly this. If you just need out-of-band access to the full dependency graph, depends is an awesome tool. Otherwise, you can take a look at the code in https://github.com/mholo65/depends/blob/master/src/Depends.Core/DependencyAnalyzer.cs and see how it does it.

@chucker
Copy link
Author

chucker commented May 4, 2020

If you just need out-of-band access to the full dependency graph

Ideally, I would want something like DependencyGraph.Packages.Any(p => p.PackageID == packageID && p.Version >= version). (Depending on which I would run different code generation steps.)

depends is an awesome tool. Otherwise, you can take a look at the code in https://github.com/mholo65/depends/blob/master/src/Depends.Core/DependencyAnalyzer.cs and see how it does it.

Thanks a bunch for the pointer!

I assume that means you consider this kind of functionality outside the scope of Buildalyzer? (Which, fair enough.)

@daveaglick
Copy link
Collaborator

I assume that means you consider this kind of functionality outside the scope of Buildalyzer?

Yeah, probably. I have to constantly fight the urge to add all kinds of extra functionality - there's a lot that could be done after the build, but it's hard enough keeping everything up to date with MSBuild and incrementing project types and versions. Might make a cool third-party extension though 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discussion/Question Discussions or questions about the code
Projects
None yet
Development

No branches or pull requests

2 participants