I know this is an old question, but since it never was answered and got a few upvotes, I thought I'd take a stab.
Here is an example from another SO question/answer about setting build date in BeforeBuild with a custom task in the csproj file:
<PropertyGroup>
<AttribCommand>chmod a+w $(MSBuildProjectDirectory)/BuildMetadata.cs</AttribCommand>
</PropertyGroup>
<UsingTask AssemblyFile="$(BuildExtensionsPath)\Foo.Framework.BuildExtensions.dll" TaskName="Foo.Framework.BuildExtensions.BuildDateTask" />
<Target Name="BeforeBuild">
<Exec Command="$(AttribCommand)" />
<BuildDateTask FilePath="$(MSBuildProjectDirectory)\BuildMetadata.cs" />
</Target>
Apologies if I misunderstood what was intended by "custom build command".