dotnet / msbuild

The Microsoft Build Engine (MSBuild) is the build platform for .NET and Visual Studio.
https://docs.microsoft.com/visualstudio/msbuild/msbuild
MIT License
5.15k stars 1.34k forks source link

Document common hook points for build extensions #10143

Open rainersigwald opened 2 weeks ago

rainersigwald commented 2 weeks ago

We have https://learn.microsoft.com/visualstudio/msbuild/msbuild-targets#sdk-and-default-build-targets but it's not super clear, I think it'd be helpful to have more clear documentation for common use cases.

(https://mastodon.social/@mcc/112451423829765088)

Some examples

Scenario Hook point
"I just need to do something early in the build" BeforeTargets="BeforeBuild"
"I need to modify the list of resolved references before anything uses it" AfterTargets="ResolveReferences"
"I want to generate some C# source" BeforeTargets="BeforeCompile"
"I have some files that I would want to add to Content or None to get copied to the output, but I generate them during the build" BeforeTargets="AssignTargetPaths"
"I need to produce or change an output before this project is done" AfterTargets="AfterBuild"
rainersigwald commented 2 weeks ago

Added

"I have some files that I would want to add to Content or None to get copied to the output, but I generate them during the build"

thanks to https://mastodon.social/@mcc/112452180875718741