msbuild icon indicating copy to clipboard operation
msbuild copied to clipboard

[Feature Request]: Add ProjectGraph APIs for target framework negotiation

Open tmat opened this issue 1 year ago • 0 comments

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

tmat avatar Apr 19 '24 16:04 tmat