How To: Ensure changes to a custom target file prompt a rebuild

One of the advantages to using MSBuild is the smarts it has to do reliable incremental builds. One pitfall you might hit when writing your own custom .targets file is that changes to your targets file don't cause a rebuild. In general, if you're changing your custom build process it's highly likely that things should re-build :)

I never actually realized this was a problem until I was chatting with Rajeev about my other issue. In the conversation he mentioned the clever way to avoid this: add your targets file to the MSBuildAllProjects property. The CoreCompile task takes this property as an input, so any changes to any of the targets files cause re-compilation.

To add to this property in your own targets files, do something like this:

<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);MyCustomProcess.targets</MSBuildAllProjects>
</PropertyGroup>

[ Author: Neil Enns ]