I was messing around today with my latest custom task (more on that later, as soon as I can find somewhere to post it), and needed to find a way to tell the target that it depended on the actual project file. I wanted to force the target, and by extension my task, to get run whenever the project file changed.

A quick trip down the hall to Rajeev revealed an elegant solution: the MSBuildProjectFile property. This gets set to the name of the current leaf project file. I'm now using it like this:

<Target Name="BeforeBuild" Inputs="$(MSBuildProjectFile)" Outputs="@(AssemblyInfo)">
   <AssemblyInfo [stay tuned for more details on what this task is!]/>
</Target>

Now whenever the project file changes the target gets run. For reference, MSDN has a list of all the special properties that MSBuild knows about.

[ Author: Neil Enns ]