[Feature Request]: Add ProjectGraph APIs for target framework negotiation
- Dominant language
- C#
- Stars
- 5.5k
- Forks
- 1.5k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 133
Description
### Summary
With current ProjectGraph APIs one can analyze project dependencies and retrieve evaluation results. However, given a (multi-targeted) project and a TFM we can't determine from the graph, which nodes of the referenced multi-targeted projects match that specific TFM. This makes it hard to determine values of properties/items across project dependencies.
### Background and Motivation
dotnet-watch uses ProjectGraph to determine various properties of the projects that affect its behavior. E.g. to distinguish between Blazor Hosted app and Blazor WASM client app we need to look at project dependencies and check their `ProjectCapability` items. Currently these specific capabilities do not change between TFMs in practice. However, it is entirely possible that in future we might encounter such scenarios, or other cases where we need to analyze TFM-specific project dependency.
### Proposed Feature
There are multiple options how this feature may be implemented and exposed as public API.
One option is, for example, to specify an optional parameter to the ProjectGraph constructor that instructs it to only include project nodes that match the given TFM (create a subgraph).
Another option might be to add method `ProjectGraphNode? GetProjectReference(string targetFramework)` that returns the node that matches the given TFM for each project node (or null if none does).
### Alternative Designs
_No response_
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading the ProjectGraph and ProjectGraphNode APIs described in the issue, including the ProjectGraph constructor and proposed GetProjectReference entry point. Compare the proposed subgraph and per-reference approaches, then determine which public API can expose TFM-specific dependency matching; done means the selected design is agreed and its behavior is covered by the project’s relevant tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100