[Bug]: Cross Targeting Rebuild target is not extensible
- Dominant language
- C#
- Stars
- 5.5k
- Forks
- 1.5k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 133
Description
### Issue Description
When rebuilding a project for multiple TFMs, the `RebuildDependsOn` property group is ignored and there is no way to extend the Rebuild process for each inner project since it ends up running `Clean;Build` for each of them. Also, there is not way to know those targets are executed in a Rebuild "context".
This makes rebuilds behave differently than for a single TFM, that can be extended through the `RebuildDependsOn`.
- Cross Targeting Rebuild: https://github.com/dotnet/msbuild/blob/c6e6cd447ac3944b351247d995f32b4d2010d409/src/Tasks/Microsoft.Common.CrossTargeting.targets#L163
- Single Target Rebuild: https://github.com/dotnet/msbuild/blob/c6e6cd447ac3944b351247d995f32b4d2010d409/src/Tasks/Microsoft.Common.CurrentVersion.targets#L979-L983
This is particularly problematic from Visual Studio, where the Rebuild project command of a project targeting multiple TFMs will always execute Rebuild for all of them by calling the Cross Targeting Rebuild target.
### Steps to Reproduce
1. Create a .NET project targeting multiple frameworks (i.e., MAUI or a console app targeting .NET 6 and 7)
2. Add an extra target to the `RebuildDependsOn` property group
3. Rebuild the project from Visual Studio or from .NET CLI without a specific target framework
### Expected Behavior
Your target should be executed.
If `RebuildDependsOn` is not available for the outer project, at least there should be a way to extend Rebuild in that scenario or a property that can signal that the Clean and Build targets are executed as part of a Rebuild.
### Actual Behavior
Your target is not executed
### Analysis
_No response_
### Versions & Configurations
_No response_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.