Running a target before the CoreBuild?

Viewed 4210

I'm adding a custom .tt template generation target to my project to run before CoreBuild, and there appear to be 2 ways of doing it:

<Project...>
    <Target Name="TransformOnBuild" AfterTargets="BeforeBuild">
</Project>

and

<Project...>
    <Target Name="TransformOnBuild" BeforeTargets="CoreBuild">
</Project>

If my target should run before my project is built, as the project relies on it, would it be better for me to use the latter? I've seen the former used to do things like generate text templates, but it seems like an unreliable way to do it because it might get run after CoreBuild, which is too late. Or is there some reason why AfterTargets="BeforeBuild" is still guaranteed to run before the core build?

I've also seen BeforeTargets="BeforeBuild" which will build even earlier. Is this a better place to put a `.tt text generation target?

3 Answers
Related