Add BeforeMicrosoftNETSdkTargets
Add a hook similar to AfterMicrosoftNETSdkTargets, BeforeTargetFrameworkInferenceTargets, CustomBeforeMicrosoftCommonCrossTargetingTargets, etc.
This provides a unified entry point for custom msbuild SDKs and msbuild NuGet packages to execute just after the project file regardless of whether the build is cross targeting or not.
My main use case for this is a custom msbuild SDK that sets the TargetFrameworks based on a property set in the project file.
My main use case for this is a custom msbuild SDK that sets the TargetFrameworks based on a property set in the project file.
We use BeforeTargetFrameworkInferenceTargets in dotnet/runtime for that. Why can't you use that instead?
We use
BeforeTargetFrameworkInferenceTargetsin dotnet/runtime for that. Why can't you use that instead?
Because at that point the decision of whether the build is cross targeting or not is already made (actually it's made at the very beginning of Microsoft.NET.Sdk's Sdk.targets) so you can only set TargetFramework not TargetFrameworks.
@baronfel we had a discussion about adding additional hook points but I'm not sure where that discussion was. Thoughts?
@baronfel
This looks generally ok, do we doc the AfterX target anywhere that we'd need to update now that this hook is available?
Looking at the existing AfterSdk... targets, there are only ~150 repos on GitHub that use this mechanism, and the vast majority of those are clones of MS-authored repos like the SDK, xamarin, etc - this means that the scope of adoption is probably quite low and we won't need to worry about this going viral.