How to display msbuild errors on the overview page from TeamCity
You can specify log for MSBuild
Parse error from log or attach whole log as build artifact.
##teamcity[publishArtifacts '.\msbuild.log']
To fail build you can use the following message
Write-Output "##teamcity[message text='MS Build failed' status='ERROR']"
You can get all messages that can be used here