-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Roslyn is in the process of attempting to move to the new project file syntax + use directory build props / targets files. This has been a very laborious process because rather than be a syntactic shift in how build files are defined, it's actually a rather big semantic shift as well. This is due to rather large changes in when items get executed.
In the old world our project files were defined as such:
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\..\..\build\Targets\Settings.props" />
....
<Import Project="..\..\..\..\build\Targets\Imports.targets" />
</Project>This structure is not particularly specific to Roslyn. It is used in many non-trivial solutions that need to support global configuration and targets.
The key feature of this structure is that it gives us complete control over when our global files get executed. In particular it allows us to control build elements before and after the standard props and targets are imported. Note: that is four locations, not two: before props, after props, before targets, after targets. That flexibility is useful in constructing custom build logic and allowing builds to work around bugs in the core targets.
This level of flexibility is simply not present in the new project file syntax + dir props files. The exact points which could be hooked before simply cannot be anymore. In particular it's not possible to properly hook after common targets (which is where we typically work around bugs in the build).
There are rough equivalent hooks for before / after common props. But there are no equivalent hooks for before / after targets. This leads to blocking issues in Roslyn adopting the new format. This is because we relied on after targets to work around bugs / limitation in the SDK. Lacking an equivalent hook we can't work around the bugs anymore and are blocked.
I will continue to push on the bugs. But at the same time it seems we should address the more fundamental issue here. The new system needs to have equivalent hooking points else other builds are likely to be blocked from migrating as well. This should be a simple enough change, just need to add the following to the top / bottom of Sdk.targets
<Import Project="$(CustomBeforeSdkTargets)" Condition="'$(CustomBeforeSdkTargets)' != ''" />
...
<Import Project="$(CustomAfterSdkTargets)" Condition="'$(CustomAfterSdkTargets)' != ''" />