Hi ,
Here you go with the settings so that the warning will get treated as error in Team Build(TFS 2010).
Provide below value for the section MSBuild Arguments(See screen shot)
/p:TreatWarningsAsErrors="true"
And after that all the warnings would get treated as error J