To access the TFS Build Definition can access the IIRC through the database since you're using XAML buildl definition. You'll need to pull it out of the TFS configuration db.
I want the TFS build to be in failed state in case any warnings come up in the solution
You should try to edit the msbuild parameters inside the build definition and cause failure if warning comes up. This can be done through TreatWarningsAsErrors msbuild property